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

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

Open
prodrive11 opened this issue Oct 18, 2022 · 1 comment
Open
Labels

Comments

@prodrive11
Copy link

prodrive11 commented Oct 18, 2022

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
Copy link

edoreld commented Feb 28, 2023

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

edoreld referenced this issue in edoreld/socket.io-client-java Feb 28, 2023
Adds `socket.open()` line which is needed to connect to the server. 

Closes `https://github.com/socketio/socket.io-client-java/issues/725` and prevents future similar issues.
edoreld added a commit to edoreld/socket.io-client-java that referenced this issue Feb 28, 2023
Adds socket.open() line which is needed to connect to the server.

Closes socketio#725 and prevents future similar issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants