Gorilla websockets start closing after 20 clients (40 websocket connections)

1,146 views
Skip to first unread message

StCredZero

unread,
Jul 1, 2015, 6:22:49 PM7/1/15
to golan...@googlegroups.com
Hi,

I'm writing a multiplayer game server using Gorilla websockets to talk to Javascript clients. So long as I stay under 20 clients, the connections seem very stable. However, if I go too far beyond 20 clients, connections start dropping off. Each client makes two websocket connections, one to a "control" server, another to an "instance" server.

The Error that comes back in the server log reads, "websocket: close 1006 unexpected EOF" -- which would seem to indicate that something is happening on the server, as 1006 is never sent over the connection. I've tried looking at chrome://net-internals/#events but nothing looks too out of the ordinary on the client side. (Basically looks like the server closes the connection and the browser behaves accordingly.) I've tried disabling the firewall, but this doesn't seem to make a difference. I've tried spawning phantomjs 2.0.0 instances on the server machine, but that obeys the same limit of around 20 stable clients. The same goes for phantomjs 2.0.0 clients on a laptop or regular browsers on 5 machines in the office.

I have the read and write deadlines set to about 250 years in the future:

    var deadline = time.Now().Add(time.Duration(time.Hour * 2242560))
    nc.ws.SetWriteDeadline(deadline)
    nc.ws.SetReadDeadline(deadline)

What am I missing here, and what other tools can I try to diagnose the problem with?

--SCZ



Naoki INADA

unread,
Jul 1, 2015, 7:58:59 PM7/1/15
to golan...@googlegroups.com
What browser do you use?
What happens when you open browser windows in several machines?
I suspect your new tab/window closes old connection in background tab/windows.

http://stackoverflow.com/questions/22866552/http-simultaneous-connections-per-host-limit-are-per-tab-browser-instance-or

jo...@proto3.com

unread,
Jul 29, 2015, 1:50:27 PM7/29/15
to golang-nuts, gary...@gmail.com
Did you ever solve this, we are having exact same issue? After 20 clients are so, we get "websocket: close 1006 unexpected EOF"

Thanks in advance.

On Thursday, July 2, 2015 at 8:21:10 AM UTC-7, gary b wrote:
The "websocket: close 1006 unexpected EOF" error is returned when the client closes the connection before sending a close frame.  

To diagnose the problem, I suggest logging the error, open and close events on the client. The close event status codes might provide some insight into why the client is closing the connection. The error event is fired on protocol errors. If the event is fired before the open event, then there's some sort of handshake failure. If the error event is fired after the open event, then there's a problem with the data sent over the connection.

Jeffrey Smith

unread,
Jul 29, 2015, 3:00:28 PM7/29/15
to golang-nuts, gary...@gmail.com, jo...@proto3.com
This got posted to reddit as well https://www.reddit.com/r/golang/comments/3bt1ej/gorilla_websockets_start_closing_after_20_clients/ My money from the code is on s/he not setting a ping + pong on the server.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages