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.31k stars 969 forks source link

2.1.0 client doesn't connect to 4.5.2 node server, no errors [kotlin] #725

Open prodrive11 opened 1 year ago

prodrive11 commented 1 year ago

Server:

    "socket.io": "4.5.2",  
    "socket.io-client": "4.5.2", 

JS/Postman client connects correctly to server. Kotlin client does nothing. No callbacks are executed, socket.connected stays false.

jvm: openjdk-18.0.1.1
paltform/os: ubuntu 21.10 (it's not Android client)

import io.socket.client.IO
import io.socket.client.Socket
import java.net.URI

class ServiceEndpoint() {
    private var socket: Socket
    private var uri: URI = URI.create("ws://localhost:3333/")

    init {
        var options = IO.Options.builder().build()
        socket = IO.socket(uri, options)
        socket.on(Socket.EVENT_CONNECT) { println("Socket connected!") }
        socket.on(Socket.EVENT_CONNECT_ERROR) {args -> println("connection failed: $args")}
        socket.io().on(Manager.EVENT_ERROR) { args -> println("error: $args")}
    }

    fun run(){
        socket.connect() 
        socket.emit("status", "hello")
    }

}
edoreld commented 1 year ago

@prodrive11 try adding socket.open() after socket = IO.socket(uri, options)