mrniko / netty-socketio

Socket.IO server implemented on Java. Realtime java framework
Apache License 2.0
6.77k stars 1.65k forks source link

Throw IllegalStateException: null when client disconnect the socketio #730

Open kdzxiaoli opened 4 years ago

kdzxiaoli commented 4 years ago

socketio version is 1.7.17

2019-12-31 02:35:12.535 [nioEventLoopGroup-8-1] ERROR [com.corundumstudio.socketio.handler.InPacketHandler:95] [,] - Error during data processing. Client sessionId: 80a76092-0bcc-4e01-ba39-3eb15a0542e8, data: java.lang.IllegalStateException: null at com.corundumstudio.socketio.protocol.PacketType.valueOf(PacketType.java:48) ~[netty-socketio-1.7.17.jar!/:?] at com.corundumstudio.socketio.protocol.PacketDecoder.readType(PacketDecoder.java:86) ~[netty-socketio-1.7.17.jar!/:?] at com.corundumstudio.socketio.protocol.PacketDecoder.decode(PacketDecoder.java:160) ~[netty-socketio-1.7.17.jar!/:?] at com.corundumstudio.socketio.protocol.PacketDecoder.decodePackets(PacketDecoder.java:142) ~[netty-socketio-1.7.17.jar!/:?] at com.corundumstudio.socketio.handler.InPacketHandler.channelRead0(InPacketHandler.java:65) ~[netty-socketio-1.7.17.jar!/:?] at com.corundumstudio.socketio.handler.InPacketHandler.channelRead0(InPacketHandler.java:36) ~[netty-socketio-1.7.17.jar!/:?] at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:306) ~[netty-codec-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1421) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:930) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at com.corundumstudio.socketio.transport.WebSocketTransport.channelRead(WebSocketTransport.java:95) ~[netty-socketio-1.7.17.jar!/:?] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) ~[netty-codec-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) ~[netty-codec-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at com.corundumstudio.socketio.transport.PollingTransport.channelRead(PollingTransport.java:109) ~[netty-socketio-1.7.17.jar!/:?] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at com.corundumstudio.socketio.handler.AuthorizeHandler.channelRead(AuthorizeHandler.java:137) ~[netty-socketio-1.7.17.jar!/:?] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:108) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:328) ~[netty-codec-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:302) ~[netty-codec-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1421) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:930) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:697) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:632) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:549) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:511) ~[netty-transport-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:918) ~[netty-common-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.39.Final.jar!/:4.1.39.Final] at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.39.Final.jar!/:4.1.39.Final] at java.lang.Thread.run(Thread.java:834) [?:?]

JackyChan commented 4 years ago

Encountered the same problem.

marhali commented 4 years ago

Same problem here.

JackyChan commented 4 years ago

It seems that decode packet with namespace incorrect. I fixed that by modify the com.corundumstudio.socketio.protocol.PacketDecoder. readNamespace(ByteBuf frame) method. I have not test it deeply. But it solved the problem. The code is here.

    private String readNamespace(ByteBuf frame) {
        /**
         * namespace post request with url queryString, like
         *  /message?a=1,
         *  /message,
         */
        int endIndex = frame.bytesBefore((byte)'?');
        if(endIndex > 0){
            return readString(frame,endIndex);
        }
        endIndex = frame.bytesBefore((byte)',');
        if(endIndex > 0){
            // modified is here, just skip the ',' after namespace
            String nsp = readString(frame,endIndex);
            frame.readByte(); // skip ,
            return nsp;
        }
        return readString(frame);
    }
findfz commented 4 years ago

I'm having the same problem.

socketio version is 1.7.7

996kid commented 3 years ago

good good @JackyChan

FuYouJ commented 2 years ago

我也遇到了这个问题,有命名空间始终会有这个错误,没有命名空间就不会