Hello,
I am trying to get the local IP / LAN IP of a server which is having 50-60 API calls per second.
I am using below code but I face route ip+net: netlinkrib: too many open files
lot of errors.
I tried commented code as well and was getting same error.
func GetOutboundIP() string {
/* conn, err := net.Dial("udp", "8.8.8.8:80")
if err != nil {
log.Println(err)
}
defer conn.Close()
localAddr := conn.LocalAddr().(*net.UDPAddr)
return localAddr.IP */
addrs, err := net.InterfaceAddrs()
if err != nil {
log.Println(err)
return ""
}
for _, a := range addrs {
if ipnet, ok := a.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
if ipnet.IP.To4() != nil {
return ipnet.IP.String()
}
}
}
return ""
}
Can you please advise how can I solve this error? I checked online reference but couldn’t find find relevant solution.
P.S. - Environment is running on load balancer behind proxy.
Edit :
ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 256974
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
**open files (-n) 102400**
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
**max user processes (-u) 256974**
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited