netty-socketio
netty-socketio copied to clipboard
socket.io v4.6.0 js library cannot decode binary message from netty-socketio 2.0.6
byte buffer in server side before call sendEvent as below:
but data received by js side have a byte (value 4) more
then I find reason is code in EncoderHandler.handleWebsocket function line 261 ( outBuf.writeByte(4); )
for (ByteBuf buf : packet.getAttachments()) {
ByteBuf outBuf = encoder.allocateBuffer(ctx.alloc());
outBuf.writeByte(4);
outBuf.writeBytes(buf);
if (log.isTraceEnabled()) {
log.trace("Out attachment: {} sessionId: {}", ByteBufUtil.hexDump(outBuf), msg.getSessionId());
}
writeFutureList.add(ctx.channel().writeAndFlush(new BinaryWebSocketFrame(outBuf)));
}
is there any solution to fix this problem?
https://github.com/mrniko/netty-socketio/issues/935#issue-1939984463
Maybe the same problem. @mrniko
I'm having the same problem.
server data
client receive data
The array has one more bit in the header and the value is 4
@mrniko
怎么解决呢
怎么解决呢
看是在客户端还是在服务端解决,服务端的话encoding的位置把那个4去掉。 客户端接到 binary数据舍弃掉第一位后面正常转化成对应的结构数据。
这里的根本问题就是binary encoding的时候开头多了个4
怎么解决呢
服务端的用nodejs版本去做了,走rpc到业务。
服务器端也是一样的问题,我的解决方法是把byte[]转换成base64字符串,然后当数据传过去,客户端接受字符串,再反一下,变成byte[],就没问题了。
服务器端: 'com.corundumstudio.socketio:netty-socketio:2.0.8'
客户端:(也是java) 'io.socket:socket.io-client:2.1.0'
服务器端也是一样的问题,我的解决方法是把byte[]转换成base64字符串,然后当数据传过去,客户端接受字符串,再反一下,变成byte[],就没问题了。
服务器端: 'com.corundumstudio.socketio:netty-socketio:2.0.8'
客户端:(也是java) 'io.socket:socket.io-client:2.1.0'
太暴力了,这个流量会增加不少
这个问题很久了,还没修复,考虑弃用这个组件了