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

你好,我运行在局域网中,客户端调用方法sendMsgToServer(byte[] data, final MessageStateListener listener)向服务端发消息时会一直断开重连循环,请问怎么解决? #21

Open
17739757884 opened this issue May 24, 2021 · 6 comments

Comments

@17739757884
Copy link

No description provided.

@aLittleGreens
Copy link
Owner

那要考虑,是不是数据格式问题,导致服务端强制断开了连接

@17739757884
Copy link
Author

在客户端我使用方法sendMsgToServer(String data, ChannelFutureListener listener)向服务端发送数据是可以的,请问不可以直接发送字节数组类型的数据吗?

@aLittleGreens
Copy link
Owner

哦哦,明白了,这个你要自己改一下源码,看一下,NettyTcpClient

ch.pipeline().addLast(new StringEncoder(CharsetUtil.UTF_8)); ch.pipeline().addLast(new StringDecoder(CharsetUtil.UTF_8));<br class="Apple-interchange-newline">

@aLittleGreens
Copy link
Owner

我又新开了分支develop_2.0,支持byte[]格式,你可以参考一下

@LetExchange
Copy link

mNettyTcpClient = new NettyTcpClient.Builder()
...
.setHeartBeatData(new byte[]{0x55, 0x55, 0x55, 0x55}) //这里好像必须是以new byte[]的形式写心跳命令
...
.build();
以其他方式我的也是有断开重连的情况,应该是服务端不能解析心跳数据,断开了连接

@aLittleGreens
Copy link
Owner

aLittleGreens commented Aug 1, 2024 via email

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

3 participants