title: Websocket dialer maintain the websocket connection
body: <p>I am testing with Go websocket dialer to connect with my own websocket server.
  This is the dialer code:</p>
  <pre><code>package main
  
  import (
      &quot;log&quot;
      &quot;github.com/gorilla/websocket&quot;
  )
  
  var (
      ws  *websocket.Conn
  )
  
  func main() {
  
      //add self as sender client
      u := &quot;ws://localhost:5005/ws&quot;
      log.Printf(&quot;Connecting to %s&quot;, u)
      ws, res, err := websocket.DefaultDialer.Dial(u, nil)
      if err != nil {
          log.Println(&quot;[DIAL]&quot;, err)
      }
      log.Println(ws)
      log.Println(res)
  }
  </code></pre>
  <p>and my server code:</p>
  <pre><code>    package main
      
      import (
          &quot;fmt&quot;
          &quot;io/ioutil&quot;
          &quot;log&quot;
          &quot;net/http&quot;
          &quot;pubsubserver/pubsub&quot;
      
          &quot;github.com/gorilla/websocket&quot;
          uuid &quot;github.com/satori/go.uuid&quot;
          &quot;github.com/valyala/fasthttp&quot;
      )
      
      var upgrader = websocket.Upgrader{
          ReadBufferSize:  1024,
          WriteBufferSize: 1024,
      }
      
      
      func websocketHandler(w http.ResponseWriter, r *http.Request) {
          upgrader.CheckOrigin = func(r *http.Request) bool { return true }
          conn, err := upgrader.Upgrade(w, r, nil)
          if err != nil {
              log.Println(err)
              return
          }
          
          //... some process to add client
      
          fmt.Println(&quot;new client connected.&quot;)
      
          for {
             //... some process to handle client message
              }
              ps.HandleReceivedMessage(client, messageType, p)
          }
      }
      
      func main() {
          http.HandleFunc(&quot;/&quot;, func(w http.ResponseWriter, r *http.Request) {
              http.ServeFile(w, r, &quot;static&quot;)
          })
          http.HandleFunc(&quot;/ws&quot;, websocketHandler)
      
          err := http.ListenAndServe(&quot;:5005&quot;, nil)
          if err != nil {
              log.Println(&quot;http server err: &quot;,err)
      
              return
          }
  }
  </code></pre>
  <p>I run my server, the run the <code>dialer.go</code>. my server with return some message:</p>
  <blockquote>
  <p>new client connected.</p>
  </blockquote>
  <blockquote>
  <p>2020/12/03 11:01:19 connection err:  read tcp[::1]:5005-&gt;[::1]:55227: read: connection reset by peer</p>
  </blockquote>
  <p>by the log message, am I right to assume the connection is successful, but the dialer close connection immediately after success connected?</p>
  <p>How can I get the dialer to persist the connection after connected to the websocket server?</p>