netty常见错误

傻男人 1年前 ⋅ 688 阅读

netty常见错误

No buffer space available

java.net.SocketException: No buffer space available (maximum connections reached?): connect

当客户端连接大道16000左右的时候,服务端无异常,客户端出现上面的错误信息

解决方式:

通过DOS下的netstat -a -n 命令,看到客户端使用的端口号是从49152-65535这一段,而49152之前的都没有使用,为了遵守IANA的推荐,把范围扩展成49152到65535

由于系统分配的端口不够用导致的报错,修改端口配置如下:

netsh int ipv4 set dynamicport tcp start=1025 num=64510

Too many open files

java.io.IOException: Too many open files
    at sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method)
    at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:422)
    at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:250)
    at org.apache.tomcat.util.net.NioEndpoint$Acceptor.run(NioEndpoint.java:453)
    at java.lang.Thread.run(Thread.java:748)

产生的原因: 1、查看每个用户允许打开的最大文件数

[root@e68-master ~]# ulimit -aulimit -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) 200484
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024

发现系统默认的是open files (-n) 1024

修改这个限制 在文件/etc/security/limits.conf中加入以下内容


* soft nofile 65536 
* hard nofile 65536

重启服务器 reboot


全部评论: 0

    我有话说: