Closed SkyperTHC closed 1 year ago
According to https://tip.golang.org/doc/go1.19, version 1.19 should be raising this limit to the max allowed by default:
On Unix operating systems, Go programs that import package os now automatically increase the open file limit (RLIMITNOFILE) to the maximum allowed value; that is, they change the soft limit to match the hard limit. This corrects artificially low limits set on some systems for compatibility with very old C programs using the [select](https://en.wikipedia.org/wiki/Select(Unix)) system call. Go programs are not helped by that limit, and instead even simple programs like gofmt often ran out of file descriptors on such systems when processing many files in parallel. One impact of this change is that Go programs that in turn execute very old C programs in child processes may run those programs with too high a limit. This can be corrected by setting the hard limit before invoking the Go program.
I tested with the following on a Linux machine with a soft limit of 1024:
var limit syscall.Rlimit
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit)
if err != nil {
panic(err.Error())
}
fmt.Printf("%v cur, %v max\n", limit.Cur, limit.Max)
Output:
1048576 cur, 1048576 max
Are you using Go 1.19?
yepp, my bad. Was an old Go version.
Thanks for the great work.
default soft limit for
ulimit -n
is 1024. Would be nice ifwiretap
sets this to the max allowed. Otherwise connections start dropping if more than 1k are open.current work around is
ulimit -n $(ulimit -Hn)
before starting wiretap.