Lihuanghe / SMSGate

这是一个在netty4框架下实现的三网合一短信网关核心框架,支持(cmpp/smpp3.4/sgip1.2/smgp3) 短信协议解析,支持长短信合并和拆分,也支持wap短信和闪信。
Apache License 2.0
902 stars 449 forks source link

长连cmpp网关,会报connection reset by peer #6

Closed wiselyman closed 7 years ago

wiselyman commented 7 years ago

作者您好,我也遇到了这样的错误,这个错误发生有概率,我目前也不好重现,有时候一天出现,有时候几天出现,错误日志如下:

16:04:39.777 [workGroup1] TRACE entity.client - [id: 0x92d969f2, L:/172.17.0.3:51331 - R:/183.230.96.94:17890] FLUSH
16:04:39.777 [workGroup1] TRACE entity.client - [id: 0x92d969f2, L:/172.17.0.3:51331 - R:/183.230.96.94:17890] FLUSH
16:04:39.825 [workGroup1] TRACE entity.client - [id: 0x92d969f2, L:/172.17.0.3:51331 - R:/183.230.96.94:17890] RECEIVED: 13B
         +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 00 00 00 0d 80 00 00 08 1e 4e 22 3e 00          |.........N">.   |
+--------+-------------------------------------------------+----------------+
16:04:39.825 [workGroup1] DEBUG entity.client - Receive:DefaultMessage [packetType=CMPPACTIVETESTRESPONSE, header=DefaultHeader [commandId=2147483656, sequenceId=508437054], getClass()=class com.zx.sms.codec.cmpp.msg.CmppActiveTestResponseMessage]
16:05:09.825 [workGroup1] DEBUG entity.client - Send:DefaultMessage [packetType=CMPPACTIVETESTREQUEST, header=DefaultHeader [commandId=8, sequenceId=508437055], getClass()=class com.zx.sms.codec.cmpp.msg.CmppActiveTestRequestMessage]
16:05:09.825 [workGroup1] TRACE entity.client - [id: 0x92d969f2, L:/172.17.0.3:51331 - R:/183.230.96.94:17890] WRITE: 12B
         +-------------------------------------------------+
         |  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f |
+--------+-------------------------------------------------+----------------+
|00000000| 00 00 00 0c 00 00 00 08 1e 4e 22 3f             |.........N"?    |
+--------+-------------------------------------------------+----------------+
16:05:09.825 [workGroup1] TRACE entity.client - [id: 0x92d969f2, L:/172.17.0.3:51331 - R:/183.230.96.94:17890] FLUSH
16:05:09.825 [workGroup1] TRACE entity.client - [id: 0x92d969f2, L:/172.17.0.3:51331 - R:/183.230.96.94:17890] FLUSH
16:05:09.874 [workGroup1] TRACE entity.client - [id: 0x92d969f2, L:/172.17.0.3:51331 - R:/183.230.96.94:17890] EXCEPTION: java.io.IOException: Connection reset by peer
java.io.IOException: Connection reset by peer
        at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
        at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
        at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
        at sun.nio.ch.IOUtil.read(IOUtil.java:192)
        at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380)
        at io.netty.buffer.UnpooledUnsafeDirectByteBuf.setBytes(UnpooledUnsafeDirectByteBuf.java:357)
        at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:898)
        at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:242)
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:119)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:528)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:485)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:399)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:371)
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
        at java.lang.Thread.run(Thread.java:745)
16:05:09.875 [workGroup1] TRACE entity.client - [id: 0x92d969f2, L:/172.17.0.3:51331 ! R:/183.230.96.94:17890] INACTIVE
16:05:09.875 [workGroup1] TRACE entity.client - [id: 0x92d969f2, L:/172.17.0.3:51331 ! R:/183.230.96.94:17890] UNREGISTERED

期待您的答复。

Lihuanghe commented 7 years ago

java.io.IOException: Connection reset by peer 收到了对端的RESET包,连接断了。可能的话,让对方查查为什么断连。否则自己增加断线重连机制吧。