Getting 'unexpected EOF' in gorilla websockets
<p>I have the following read pump for a gorilla websockets connection in Go.</p>

<pre><code>func (c *connection) readPump() {

//function to close the websocket
defer func() {
    socketsHub.unregister &lt;- c
    c.ws.Close()
}()

c.ws.SetReadLimit(maxMessageSize)
c.ws.SetReadDeadline(time.Now().Add(pongWait))
c.ws.SetPongHandler(func(string) error {
    c.ws.SetReadDeadline(time.Now().Add(pongWait))
    return nil
})

for {

    //create a new socketMessage
    message := socketMessage{}

    //get the json message from the socket
    err := c.ws.ReadJSON(message)

    if err != nil {
        log.Println(err)
        break
    }
    //add the connection to the message
    message.Connection = c

    shouldBroadcast := message.Process()

    //if the new message should be broadcasted to any user (includeing the
    //one who sent it)
    if shouldBroadcast {
        socketsHub.broadcast &lt;- message
    }
}
</code></pre>

<p>}</p>

<p>This is the code we are using on the frontend:</p>

<pre><code>if (window["WebSocket"]) {
  conn = new WebSocket("wss://localhost/api/ws")

  conn.onclose = function(evt) {
    console.log($("&lt;div&gt;&lt;b&gt;Connection closed.&lt;/b&gt;&lt;/div&gt;"))
  }
} else {
  console.log($("&lt;div&gt;&lt;b&gt;Your browser does not support WebSockets.&lt;/b&gt;&lt;/div&gt;"))
}
</code></pre>

<p>Everytime I load any page I get an <code>'websocket: close 1005'</code> error. I am about to go crazy. Any help would be great.</p>