go-socket.io | io library for golang , a realtime application framework | Socket library
kandi X-RAY | go-socket.io Summary
kandi X-RAY | go-socket.io Summary
socket.io library for golang, a realtime application framework.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of go-socket.io
go-socket.io Key Features
go-socket.io Examples and Code Snippets
Community Discussions
Trending Discussions on go-socket.io
QUESTION
I am using a go lib: github.com/googollee/go-socket.io I am wondering how to write a very simple test for connection event, ex, if i want to check no error is returned.
...ANSWER
Answered 2021-Aug-15 at 07:37Create a seperate function which takes the socketio.Conn interface as a parameter, and pass that to server.OnConnect
instead of an anonymous function.
Then you can mock the socketio.Conn to unit test your function.
For example, change your code snippet to:
QUESTION
I have a server on GoLang and googollee/go-socket.io
.
When the server and the client work on the same port, the sockets work normally. But when I start they are on different ports an error occurs on the client:
WebSocket connection to 'ws://localhost:4444/socket.io/?EIO=3&transport=websocket&sid=6' failed: Error during WebSocket handshake: Unexpected response code: 403
POST http://localhost:4444/socket.io/?EIO=3&transport=polling&t=NDDzcYM&sid=5 400 (Bad Request)
GET http://localhost:4444/socket.io/?EIO=3&transport=polling&t=NDDzcYC&sid=5 400 (Bad Request)
WebSocket connection to 'ws://localhost:4444/socket.io/?EIO=3&transport=websocket&sid=5' failed: Error during WebSocket handshake: Unexpected response code: 403
And on the server:
connected: 1 closed client namespace disconnect meet error: json: cannot unmarshal object into Go value of type string connected: 2
This is my code:
...ANSWER
Answered 2020-Jul-14 at 18:25The error message indicates that the server tried to unmarshal your JSON object into a string, but it expected something different.
The reason for that is in your method definition:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install go-socket.io
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page