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

一但有异常Socket连接就断开 #13

Open
mrsuhx opened this issue Dec 26, 2019 · 5 comments
Open

一但有异常Socket连接就断开 #13

mrsuhx opened this issue Dec 26, 2019 · 5 comments

Comments

@mrsuhx
Copy link

mrsuhx commented Dec 26, 2019

作者你好,非常感谢你的demo思路,我在运行项目过程中发现程序一旦有什么异常情况就会把Socket连接断开,这不是我想要的,请问具体需要在哪个地方做调整?

@aLittleGreens
Copy link
Owner

请举个例子,哪个地方发生异常了呢

@mrsuhx
Copy link
Author

mrsuhx commented Dec 26, 2019

感谢作者回复,具体应该是在NettyTcpClient和NettyClientHandler这两个地方捕获到了异常,原因是客户端的onMessageResponseClient方法里有发生异常情况
client
handler

@aLittleGreens
Copy link
Owner

可以在NettyClientHandler中的channelRead0,捕获这个异常

@mrsuhx
Copy link
Author

mrsuhx commented Dec 26, 2019

感谢作者回复

  1. 是在方法channelRead0里的listener.onMessageResponseClient(msg, index)用try catch捕获一下异常吗?
  2. 想请教一下NettyClientHandler中的exceptionCaught是socket连接中全局有异常就会触发吗?
  3. NettyTcpClient中像我那样注释代码正确吗,会不会影响netty的断线重连机制?

@aLittleGreens
Copy link
Owner

1、是的
2、是的
3、会影响重连

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