socketio / socket.io-client-java

Full-featured Socket.IO Client Library for Java, which is compatible with Socket.IO v1.0 and later.
https://socketio.github.io/socket.io-client-java/installation.html
Other
5.34k stars 975 forks source link

Client close with reason ping timeout #632

Closed gureuso closed 3 years ago

gureuso commented 3 years ago

server

io.on('connection', (socket) => {
  console.log('user connected');

  socket.on('abc', data => {
    console.log(data);
    socket.emit('abc', {comment: 'server'})
  });

  socket.on('disconnect', () => {
    console.log('user disconnected');
  });

  socket.on('connect_error', (error) => {
    console.log(error);
  });
});

http.listen(3001, () => {
  console.log('listening on *:3001');
});

client

socket = IO.socket("http://gureuso.me");
socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
    @Override
    public void call(Object... args) {
        Log.i(TAG, "connect");
        socket.emit("abc", "client-android");
    }
}).on("abc", new Emitter.Listener() {
    @Override
    public void call(Object... args) {
        Log.i(TAG, args[0].toString());
    }
}).on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
    @Override
    public void call(Object... args) {
        Log.i(TAG, Arrays.toString(args));
    }
}).on(Socket.EVENT_CONNECT_ERROR, new Emitter.Listener() {
    @Override
    public void call(Object... args) {
        Log.i(TAG, Arrays.toString(args));
    }
});

Log.i(TAG, "connection");
socket.connect();

server error

socket.io:server incoming connection with id KMeDyT5ZUPc3wKB9AAAs +5s
socket.io:client no namespace joined yet, close the client +5s
socket.io:client client close with reason ping timeout +170ms
122.42.111.209 - - [12/Nov/2020:00:13:57 +0900] "GET /socket.io/?EIO=3&transport=polling HTTP/1.1" 200 96 "-" "okhttp/3.8.1"
122.42.111.209 - - [12/Nov/2020:00:13:57 +0900] "POST /socket.io/?EIO=3&transport=polling HTTP/1.1" 400 43 "-" "okhttp/3.8.1"

client error

I/SocketService: [io.socket.engineio.client.EngineIOException: server error]

I don't know why client close with reason ping timeout. I used proxy 3001 to 80.

gureuso commented 3 years ago

This problem is server version issue. Change socket.io server version 3.0.1 to 2.3.0. It is ok..