title: Websocket timing out too soon
body: <p>I've set up a standard Phoenix websocket/channel environment but I am not using the socket.js provided - I have my own (very simple) code that connects to the channels and topics. However, I can't get the socket to persist beyond a minute or so. Is there any way to define the timeout for sockets? I don't have any special configurations in the Phoenix-side (all standard as per the documentation)</p>
  
  <p>My javascript code is as follows:</p>
  
  <pre><code>const ws = new WebSocket(sock_url);
  ws.onmessage = (msg) =&gt; {
    const { payload, event } = JSON.parse(msg.data);
    if (!event.startsWith("phx_")) {
      onMessage(payload.body);
    }
  };
  ws.onclose = (code, reason) =&gt; {
    onClose(code, reason);
  };
  ws.onopen = () =&gt; {
    ws.send(JSON.stringify({
      topic: `users_socket:${user_id}`,
      event: "phx_join",
      payload: {},
      ref: '1'
    }));
  };
  </code></pre>
  
  <p><strong>Update</strong>: I ended up using the socket.js file that comes with Phoenix as everyone suggested - it just does everything I need. Thanks to everyone who answered :)</p>