googollee / go-socket.io

socket.io library for golang, a realtime application framework.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Client ignores Transports defined in opts

TwoNull opened this issue · comments

commented

Describe the bug
Regardless of the transports defined in opts.Transports, the Client will always dial the server using polling.Default. This causes problems if the server does not accept connections via http polling.

To Reproduce
Initialize a client using a transport other than polling.Default. Ex.

client, err := socketio.NewClient("http://127.0.0.1:8080", &engineio.Options{
	Transports: []transport.Transport{websocket.Default},
})
if err != nil {
	log.Fatal(err)
}

err = client.Connect()
if err != nil {
	log.Fatal(err)
}

Expected behavior
The Client should connect via the Transport defined in opts, however it will always connect with polling.Default.

Environment (please complete the following information):

  • Go version: 1.21.5
  • Server version go-socket.io v1.8.0-rc.1
  • Client version go-socket.io v1.8.0-rc.1

Additional context
The culprit seems to be line 68 of go-socket.io/client.go, where the the dialer is hardcoded as []transport.Transport{polling.Default} when it should be c.opts.Transport

commented

You can take a look at my code and I will test it myself to see if it works properly
#633

Is the NewClient function currently unavailable?

I downloaded the packages and called the socketio.NewClient function and it says undefine socketio.NewClient.

commented

@fullgukbap v1.8.0-rc.1