mrniko / netty-socketio

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

Redisson null pointer exception (authorizeHandler == null) #176

Closed ivankosdy closed 10 years ago

ivankosdy commented 10 years ago

Hi mrniko!

I have 2 running server instances (eg ports 8080,8081) using RedissonStoreFactory connected to the same redis server

Configuration config = new Configuration();
config.setHostname("localhost");
config.setPort(8080);
config.getSocketConfig().setReuseAddress(true);
config.setStoreFactory(new RedissonStoreFactory());

server = new SocketIOServer(config);

when client connects to 8080, server 8081 throws a null pointer exception

java.lang.NullPointerException: null
    at com.corundumstudio.socketio.store.pubsub.BaseStoreFactory$2.onMessage(BaseStoreFactory.java:48) ~[netty-socketio-1.7.3.jar:na]
    at com.corundumstudio.socketio.store.pubsub.BaseStoreFactory$2.onMessage(BaseStoreFactory.java:45) ~[netty-socketio-1.7.3.jar:na]
    at com.corundumstudio.socketio.store.RedissonPubSubStore$1.onMessage(RedissonPubSubStore.java:59) ~[netty-socketio-1.7.3.jar:na]
    at com.corundumstudio.socketio.store.RedissonPubSubStore$1.onMessage(RedissonPubSubStore.java:55) ~[netty-socketio-1.7.3.jar:na]
    at org.redisson.RedisPubSubTopicListenerWrapper.message(RedisPubSubTopicListenerWrapper.java:48) ~[redisson-1.1.5.jar:na]
    at com.lambdaworks.redis.pubsub.RedisPubSubConnection.channelRead(RedisPubSubConnection.java:118) ~[redisson-1.1.5.jar:na]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333) [netty-transport-4.0.23.Final.jar:4.0.23.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319) [netty-transport-4.0.23.Final.jar:4.0.23.Final]
    at com.lambdaworks.redis.pubsub.PubSubCommandHandler.decode(PubSubCommandHandler.java:51) [redisson-1.1.5.jar:na]
    at com.lambdaworks.redis.protocol.CommandHandler.channelRead(CommandHandler.java:52) [redisson-1.1.5.jar:na]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333) [netty-transport-4.0.23.Final.jar:4.0.23.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319) [netty-transport-4.0.23.Final.jar:4.0.23.Final]
    at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) [netty-transport-4.0.23.Final.jar:4.0.23.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333) [netty-transport-4.0.23.Final.jar:4.0.23.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319) [netty-transport-4.0.23.Final.jar:4.0.23.Final]
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:787) [netty-transport-4.0.23.Final.jar:4.0.23.Final]
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:130) [netty-transport-4.0.23.Final.jar:4.0.23.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511) [netty-transport-4.0.23.Final.jar:4.0.23.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) [netty-transport-4.0.23.Final.jar:4.0.23.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) [netty-transport-4.0.23.Final.jar:4.0.23.Final]
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) [netty-transport-4.0.23.Final.jar:4.0.23.Final]
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) [netty-common-4.0.23.Final.jar:4.0.23.Final]
    at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137) [netty-common-4.0.23.Final.jar:4.0.23.Final]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_25]

debugger says that authorizeHandler is null

could you help me with this issue please?

ivankosdy commented 10 years ago

i was using 1.7.3...

anyway i built 1.7.4 with switched order in SocketIOChannelInitializer:

authorizeHandler = new AuthorizeHandler(connectPath, scheduler, configuration, namespacesHub, factory, this, ackManager, clientsBox); factory.init(namespacesHub, authorizeHandler, jsonSupport);

and it's working fine now

mrniko commented 10 years ago

Fixed