我使用 socat 作为某些设备之间的桥梁,并像这样运行 socat(几百个实例):
socat -d -d -d -x -d -lf "/var/log/some_log_file" TCP4-LISTEN:6126,fork,max-children=1,su=nobody,reuseaddr,sndtimeo=30,rcvtimeo=30 TCP4-LISTEN:6127,reuseaddr,sndtimeo=30,rcvtimeo=30
我不断得到Resource temporarily unavailable
2015/12/18 04:48:25 socat[1868] D malloc() -> 0x1097990
2015/12/18 04:48:25 socat[1868] I setting option "fork" to 1
2015/12/18 04:48:25 socat[1868] I setting option "max-children" to 1
2015/12/18 04:48:25 socat[1868] I setting option "substuser" to 65534
2015/12/18 04:48:25 socat[1868] I setting option "so-reuseaddr" to 1
2015/12/18 04:48:25 socat[1868] D malloc(896)
2015/12/18 04:48:25 socat[1868] D malloc() -> 0x1099cf0
2015/12/18 04:48:25 socat[1868] D sigaction(17, 0x7fff3aa1a790, (nil))
2015/12/18 04:48:25 socat[1868] D sigaction() -> 0
2015/12/18 04:48:25 socat[1868] D socket(2, 1, 6)
2015/12/18 04:48:25 socat[1868] I socket(2, 1, 6) -> 4
2015/12/18 04:48:25 socat[1868] D setsockopt(4, 1, 2, {0x1}, 4)
2015/12/18 04:48:25 socat[1868] D setsockopt() -> 0
2015/12/18 04:48:25 socat[1868] D setsockopt(4, 1, 21, {0x0000001e,00000000}, 16)
2015/12/18 04:48:25 socat[1868] D setsockopt() -> 0
2015/12/18 04:48:25 socat[1868] D setsockopt(4, 1, 20, {0x0000001e,00000000}, 16)
2015/12/18 04:48:25 socat[1868] D setsockopt() -> 0
2015/12/18 04:48:25 socat[1868] D fcntl(4, 2, 1)
2015/12/18 04:48:25 socat[1868] D fcntl() -> 0
2015/12/18 04:48:25 socat[1868] D bind(4, AF=2 0.0.0.0:6126, 16)
2015/12/18 04:48:25 socat[1868] D bind() -> 0
2015/12/18 04:48:25 socat[1868] D getsockname(4, 0x7fff3aa1aee0, 0x7fff3aa1a854{16})
2015/12/18 04:48:25 socat[1868] D getsockname(, {AF=2 0.0.0.0:6126}, {16}) -> 0
2015/12/18 04:48:25 socat[1868] D listen(4, 5)
2015/12/18 04:48:25 socat[1868] D listen() -> 0
2015/12/18 04:48:25 socat[1868] I starting accept loop
2015/12/18 04:48:25 socat[1868] N listening on AF=2 0.0.0.0:6126
2015/12/18 04:48:25 socat[1868] D accept(4, 0x7fff3aa1a900, 0x7fff3aa1a860)
2015/12/18 04:48:55 socat[1868] D accept(,,) -> -1
2015/12/18 04:48:55 socat[1868] E accept(4, 0x7fff3aa1a900, {16}): Resource temporarily unavailable
2015/12/18 04:48:55 socat[1868] N exit(1)
2015/12/18 04:48:55 socat[1868] I shutdown(4, 2)
2015/12/18 04:48:55 socat[1868] D shutdown() -> 0
我已经尝试增加打开的文件和连接的数量:
ulimit -n 99999
ulimit -u 20000
ulimit -i 15000
sysctl -w fs.file-max=100000
sysctl net.core.somaxconn=10000
但这似乎不是问题所在。
在我看来,socat
无法在它正在监听的套接字上打开连接。
我试图用谷歌搜索这个错误,但是“资源暂时不可用”是一个相当宽泛的术语。
可能发生了什么?我该如何解决?