Open
Description
Describe the bug
I'm trying to reach the python-based server via java-based Socket.IO client. While the connection is successful (detected by catching EVENT_OPEN and EVENT_CONNECT events), no other responses from the server are detected.
To Reproduce
Socket.IO server version: presumably 4
Socket.IO java client version: 2.0.2
Client
public class MyApplication {
public static void main(String[] args) throws URISyntaxException {
URI uri = URI.create("http://www.example.com");
IO.Options op = new Options();
op.transports = new String[] {WebSocket.NAME};
op.reconnection = false;
op.upgrade = true;
// create socket
socket = IO.socket(uri, op);
// make subscriptions
socket.on(Socket.EVENT_CONNECT, args -> {
System.out.println("connected " + Arrays.toString(args));
// send authentication on connection
String token = "let-me-in";
sendContent("authenticate", token);
});
socket.io().on(Manager.EVENT_OPEN, args -> {
// works
System.out.println("connection opened " + Arrays.toString(args));
});
socket.on("topic", args -> {
// doesn't work
System.out.println("interesting data: " + Arrays.toString(args));
});
// connect the socket
socket.connect();
}
public static void sendContent(String operation, Object content) {
socket.emit(operation, content, (Ack) args -> {
if (args.length > 0) {
// expected {response : ok} or something similar
String response = args[0].toString();
System.out.println(operation + " response: " + response);
} else {
// I always get this reponse instead
System.out.println("empty " + operation + " response!");
}
});
}
}
Expected behavior
I expected this to open the connection, receive the authorization response, and based on the success of that to further receive the "topic" events. When I tested it on local python eventlet server it works nicely, but I can't get any response from the real one outside of connection opened []
, connected []
and empty authenticate response!
.
Platform:
- Device: PC
- OS: Windows 10