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

Intermittent connection failures #7

Open
dcormier opened this issue Nov 21, 2016 · 1 comment
Open

Intermittent connection failures #7

dcormier opened this issue Nov 21, 2016 · 1 comment

Comments

@dcormier
Copy link

dcormier commented Nov 21, 2016

There is a problem with this client that results in connection attempts failing intermittently. This is more easily reproduced by attempting to connect multiple instances of the client to a server.

Here is a gist that has a test to easily reproduce the problem. Just save the file to a directory, make sure you have the required packages, then run go test to see the failure. It will look very similar to the output below.

These packages are needed to run the tests:

go get -u github.com/googollee/go-socket.io
go get -u github.com/graarh/golang-socketio
go get -u github.com/zhouhui8915/go-socket.io-client

Here is the output of the tests:

>go test
2016/11/21 12:10:00 http: response.WriteHeader on hijacked connection
2016/11/21 12:10:00 http: response.WriteHeader on hijacked connection
2016/11/21 12:10:00 http: response.WriteHeader on hijacked connection
2016/11/21 12:10:00 http: response.WriteHeader on hijacked connection
2016/11/21 12:10:00 http: response.WriteHeader on hijacked connection
2016/11/21 12:10:00 http: response.WriteHeader on hijacked connection
2016/11/21 12:10:00 http: response.WriteHeader on hijacked connection
2016/11/21 12:10:00 http: response.WriteHeader on hijacked connection
2016/11/21 12:10:00 http: response.WriteHeader on hijacked connection
2016/11/21 12:10:00 http: response.WriteHeader on hijacked connection
--- FAIL: TestZhouhui (25.00s)
        socketio_test.go:74: [server] Listening on 127.0.0.1:58654
        socketio_test.go:113: [client] #03 connecting...
        socketio_test.go:113: [client] #04 connecting...
        socketio_test.go:113: [client] #07 connecting...
        socketio_test.go:113: [client] #01 connecting...
        socketio_test.go:113: [client] #06 connecting...
        socketio_test.go:113: [client] #05 connecting...
        socketio_test.go:113: [client] #02 connecting...
        socketio_test.go:132: Waiting for client connection attempts to finish
        socketio_test.go:113: [client] #10 connecting...
        socketio_test.go:113: [client] #08 connecting...
        socketio_test.go:113: [client] #09 connecting...
        socketio_test.go:65: [server] Client #01 connected: nu8jEhbmI38vzI_i3rUe
        socketio_test.go:65: [server] Client #02 connected: iBV0WjWVu1s29p3nJAgE
        socketio_test.go:65: [server] Client #03 connected: UeruIAXOHX5ETc8DOpzt
        socketio_test.go:65: [server] Client #04 connected: _XcPUDWA0loqGntf0E3w
        socketio_test.go:65: [server] Client #05 connected: ySSx04spjsNldmy94c0j
        socketio_test.go:65: [server] Client #06 connected: fooWr_iJ2SFQtcQzcMFr
        socketio_test.go:65: [server] Client #07 connected: UeruIAXOHX5ETc8DOpzt
        socketio_test.go:65: [server] Client #08 connected: 1HIbt6xa3QHb1sJng8be
        socketio_test.go:65: [server] Client #09 connected: I0tSRklByiasdszvBgga
        socketio_test.go:65: [server] Client #10 connected: WJF5UYjovQzQpHIkf303
        socketio_test.go:117: [client] #07 could not connect to http://127.0.0.1:58654: EOF
        socketio_test.go:121: [client] #06 connected
        socketio_test.go:121: [client] #02 connected
        socketio_test.go:121: [client] #04 connected
        socketio_test.go:121: [client] #08 connected
        socketio_test.go:121: [client] #03 connected
        socketio_test.go:121: [client] #05 connected
        socketio_test.go:117: [client] #01 could not connect to http://127.0.0.1:58654: EOF
        socketio_test.go:117: [client] #10 could not connect to http://127.0.0.1:58654: EOF
        socketio_test.go:117: [client] #09 could not connect to http://127.0.0.1:58654: EOF
FAIL
exit status 1
FAIL    github.com/dcormier/socket.io-bug       25.072s

The http: response.WriteHeader on hijacked connection messages are caused by a different issue (googollee/go-socket.io#108) and may appear regardless of whether the connection attempts were successful.

Other socket.io clients work reliably in this same scenario. This one fails.

The error being returned, "EOF", is probably the io.EOF value. I suspect that the client is expecting data to be immediately available to be read, but in fact it takes a moment for the server to send it. Sometimes the client gets to that point before the server has sent the data.

The failure almost always takes 25 seconds (the default pingInterval value). There is a second failure that's very rare and returns the same error immediately. I've included notes in the test file on reproducing this one. Very rarely, the test will actually pass. If this happens, just run it again to see it fail.

@loint
Copy link

loint commented Nov 26, 2016

+1 need to be fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants