Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ bug提交 ] 消息和推送会全部推到新开的页面 #1

Closed
MapleStoryXiaoA opened this issue Aug 16, 2019 · 7 comments
Closed

Comments

@MapleStoryXiaoA
Copy link

如题,关闭新开的页面后,再回复也不可显示
image

@dolyw
Copy link
Owner

dolyw commented Aug 16, 2019

没理解你的意思

@MapleStoryXiaoA
Copy link
Author

就是说 我在本地开了三个页面 叫小A 小B 小C
但是在小B加入时 没有通知给小A, 而是在小B的页面通知了两条
在小C加入时,没有通知A和B,而是在C的页面通知了三条

发消息也是一样 此时A发消息 只会在C的页面弹出三条

@MapleStoryXiaoA
Copy link
Author

image

@MapleStoryXiaoA
Copy link
Author

然后在C关闭页面时,报NPE

2019-08-16 17:16:13.852 ERROR 3972 --- [ntLoopGroup-3-7] c.c.s.listener.DefaultExceptionListener  : java.lang.NullPointerException

com.corundumstudio.socketio.handler.SocketIOException: java.lang.NullPointerException
	at com.corundumstudio.socketio.annotation.OnDisconnectScanner$1.onDisconnect(OnDisconnectScanner.java:42) ~[netty-socketio-1.7.17.jar:na]
	at com.corundumstudio.socketio.namespace.Namespace.onDisconnect(Namespace.java:190) ~[netty-socketio-1.7.17.jar:na]
	at com.corundumstudio.socketio.transport.NamespaceClient.onDisconnect(NamespaceClient.java:115) [netty-socketio-1.7.17.jar:na]
	at com.corundumstudio.socketio.handler.ClientHead.onChannelDisconnect(ClientHead.java:183) [netty-socketio-1.7.17.jar:na]
	at com.corundumstudio.socketio.transport.WebSocketTransport.channelInactive(WebSocketTransport.java:148) [netty-socketio-1.7.17.jar:na]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.ChannelInboundHandlerAdapter.channelInactive(ChannelInboundHandlerAdapter.java:75) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.handler.codec.MessageAggregator.channelInactive(MessageAggregator.java:417) [netty-codec-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.ChannelInboundHandlerAdapter.channelInactive(ChannelInboundHandlerAdapter.java:75) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.handler.codec.http.websocketx.extensions.compression.DeflateDecoder.channelInactive(DeflateDecoder.java:119) [netty-codec-http-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.ChannelInboundHandlerAdapter.channelInactive(ChannelInboundHandlerAdapter.java:75) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at com.corundumstudio.socketio.transport.PollingTransport.channelInactive(PollingTransport.java:190) [netty-socketio-1.7.17.jar:na]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.ChannelInboundHandlerAdapter.channelInactive(ChannelInboundHandlerAdapter.java:75) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.ChannelInboundHandlerAdapter.channelInactive(ChannelInboundHandlerAdapter.java:75) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:390) [netty-codec-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:355) [netty-codec-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1403) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:912) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.AbstractChannel$AbstractUnsafe$8.run(AbstractChannel.java:826) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute$$$capture(AbstractEventExecutor.java:163) [netty-common-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java) [netty-common-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404) [netty-common-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:495) [netty-transport-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:905) [netty-common-4.1.33.Final.jar:4.1.33.Final]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.33.Final.jar:4.1.33.Final]
	at java.lang.Thread.run(Thread.java:748) [na:1.8.0_211]
Caused by: java.lang.NullPointerException: null
	at com.example.controller.SocketHandler.lambda$sendMsg$0(SocketHandler.java:117) ~[classes/:na]
	at java.util.concurrent.ConcurrentHashMap.forEach(ConcurrentHashMap.java:1597) ~[na:1.8.0_211]
	at com.example.controller.SocketHandler.sendMsg(SocketHandler.java:115) ~[classes/:na]
	at com.example.controller.SocketHandler.onDisConnect(SocketHandler.java:96) ~[classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_211]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_211]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_211]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_211]
	at com.corundumstudio.socketio.annotation.OnDisconnectScanner$1.onDisconnect(OnDisconnectScanner.java:40) ~[netty-socketio-1.7.17.jar:na]
	... 47 common frames omitted

@dolyw
Copy link
Owner

dolyw commented Aug 16, 2019

不能是同一个Cookie域下啊,你得开不同的浏览器,或者开谷歌的无痕模式,也是处于不同的Cookie下了,这就和你登录两个淘宝京东网站,一样的帐号一样,理解了没

@MapleStoryXiaoA
Copy link
Author

理解了 谢谢 我都没开始看代码 跑了下就来提了= = 多向dalao学习!

@dolyw
Copy link
Owner

dolyw commented Aug 16, 2019

不过我这里没有继续写下去,还可以优化下

  1. 消息可以直接放后台应用里持久化
  2. 前端打开新窗口也应该判断是否存在

我只是写个小例子记录下,这个框架直接封装了,很简单的用就行,我打算接下来要用Netty去实现,都是菜鸟,共勉

@dolyw dolyw pinned this issue Aug 16, 2019
@dolyw dolyw closed this as completed Aug 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants