title: Gorilla Websocket - Read error: repeated read on failed websocket connection
body: <p>Using the gorilla websocket api for go, how do i know if a client is still connected?</p>
  
  <p>What Im trying with now is: </p>
  
  <pre><code>func Listen(ws *websocket.Conn) {
      connTimeout := 3
      timeLastSent := time.Now().Second()
  
      for ((timeLastSent + connTimeout) % 60) != time.Now().Second() {
  
          msg := Message{}
          err := ws.ReadJSON(&amp;msg)
  
          if err == websocket.ErrCloseSent {
              break
          } else if err != nil {
              continue
          }
  
          //Message recived
          EventMessage &lt;- msg
  
          timeLastSent = time.Now().Second()
      }
    //Connection timed out.
      return
  }
  </code></pre>
  
  <p>But this results in the error <code>repeated read on failed websocket connection</code>.  </p>
  
  <p>Ive been looking into using <code>ws.SetReadDeadline(t)</code>, but Ive no idea of either how to use it nor if its even the thing Im looking for.</p>
  
  <p>How should i go about this?   </p>