Search code examples
gowebsocketgorilla

Whats happend if websocket handshake timeout set 0


I wanna get some insight about Handshake Timeout in websocket. Before that, I get this error from my websocket with HandshakeTimeout I set to 10 seconds.

websocket: close 1006 (abnormal closure): unexpected EOF

I try to find how to solve this error, many groups say to increase the HandshakeTimeout.

But, my mind says different and wanna set config websocket like this:

ws := websocket.Upgrader{
    ReadBufferSize:   0,
    WriteBufferSize:  0,
    HandshakeTimeout: 0,
    CheckOrigin: func(r *nethttp.Request) bool {
        return true
    },
}

My question is. Is there any vulnerability issue or negative issue that comes up if I set HandshakeTimeout set to 0?

I'm using gorilla to setup websocket for in my code.


Solution

  • There is no timeout when the value is zero. If there is no timeout, the resources associated with the connection (including the goroutine) can be held for an arbitrary amount of time.