ws: Random disconnects with 1006 error in Firefox

  • I’ve searched for any related issues and avoided creating a duplicate issue.

Possibly related to, though couldn’t confirm: https://github.com/socketio/socket.io/issues/2016

Description

I experience random disconnects on a remote connection to a server.

The disconnects do not happen when I run the code locally or remotely in Chromium. They only occur when running the code remotely in Firefox.

I have filed a bug report with Firefox (https://bugzilla.mozilla.org/show_bug.cgi?id=1478157).

However, I do not experience these disconnects when I switch the library to socket.io, which is the reason I’m also filing a bug report here.

Reproducible in:

version: Node.js version(s): 10.9.0 OS version(s): Linux computer 4.18.3-arch1-1-ARCH Firefox 62.0.2 on archlinux

Steps to reproduce:

  1. Download and extract attached testcase
  2. Run npm install
  3. Generate a private key and ssl certificate under localhost.key and localhost.crt (or modify the code to run insecurely)
  4. If running on server/domain, modify the “localhost” string in the last line of index.js to match the domain name
  5. Run node index.js

Expected result:

When running the code on a remote server, you shouldn’t experience disconnects.

Actual result:

I experience random disconnects with this output:

  • onopen open { target: WebSocket, isTrusted: true, eventPhase: 0, bubbles: false, cancelable: false, defaultPrevented: false, composed: false, timeStamp: 208, cancelBubble: false, originalTarget: WebSocket, … } mydomain.com:8443:45:9 The connection to wss://mydomain.com:8443/ was interrupted while the page was loading. mydomain.com:8443:9:16 onerror error { target: WebSocket, isTrusted: true, currentTarget: WebSocket, eventPhase: 2, bubbles: false, cancelable: false, defaultPrevented: false, composed: false, timeStamp: 191826, cancelBubble: false, … } mydomain.com:8443:25:5 onclose close { target: WebSocket, isTrusted: true, wasClean: false, code: 1006, reason: “”, currentTarget: WebSocket, eventPhase: 2, bubbles: false, cancelable: false, defaultPrevented: false, … } mydomain.com:8443:20:5 on open open { target: WebSocket, isTrusted: true, currentTarget: WebSocket, eventPhase: 2, bubbles: false, cancelable: false, defaultPrevented: false, composed: false, timeStamp: 192111, cancelBubble: false, … }

Attachments:

testcase.tar.gz

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

@intpp and @alexanderkhivrych Does your server implement PING handling and reply with PONG? Upon receipt of a Ping frame, an endpoint MUST send a Pong frame in response, unless it already received a Close frame. https://tools.ietf.org/html/rfc6455#section-5.5.2

Reproduced with https://github.com/websockets/wscat, Chrome, Safari