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

[BUGS] Send a byte array with an additional byte of value 4 when use soket.io 4.7.5 #997

Open
lyziew opened this issue Aug 8, 2024 · 0 comments

Comments

@lyziew
Copy link

lyziew commented Aug 8, 2024

Version:

netty-socket.io:2.0.11
socket.io.client:4.7.5

backend code:

public class EventChatLauncher {
    public static void main(String[] args) throws InterruptedException {
        Configuration config = new Configuration();
        config.setHostname("localhost");
        config.setPort(9092);
        config.setMaxFramePayloadLength(1048575);
        config.setMaxHttpContentLength(1048575);
        final SocketIOServer server = new SocketIOServer(config);
        server.addEventListener("chatevent", ChatObject.class, new DataListener<ChatObject>() {
            @Override
            public void onData(SocketIOClient client, ChatObject data, AckRequest ackRequest) {
                server.getBroadcastOperations().sendEvent("chatevent", data);
                byte[] bytes = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
                server.getBroadcastOperations().sendEvent("broadcastMsg", bytes);
                client.sendEvent("msg", bytes);
            }
        });
        server.start();
        Thread.sleep(Integer.MAX_VALUE);
        server.stop();
    }
}

frontend code:

socket.on("msg", function (data) {
    console.log("msg", data);
});
socket.on("broadcastMsg", function (data) {
    console.log("broadcastMsg", data);
});

screenshot:

image

  • You see, i send 10 bytes, receive 11 bytes
  • I also test with socket.io.client 1.x 2.x 3.x, find that it run ok with 1.x and 2.x but wrong with 3.x and 4.x
  • I also find when use getBroadcastOperations().sendEvent broadcast bytes,one client receive all bytes , another client receive zero bytes
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

1 participant