Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ws

Package Overview
Dependencies
Maintainers
4
Versions
169
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ws - npm Package Compare versions

Comparing version 6.1.0 to 6.1.1

4

lib/extension.js

@@ -67,3 +67,3 @@ 'use strict';

if (start === -1) start = i;
} else if (code === 0x20/* ' ' */|| code === 0x09/* '\t' */) {
} else if (code === 0x20/* ' ' */ || code === 0x09/* '\t' */) {
if (end === -1 && start !== -1) end = i;

@@ -107,3 +107,3 @@ } else if (code === 0x3b/* ';' */ || code === 0x2c/* ',' */) {

start = end = -1;
} else if (code === 0x3d/* '=' */&& start !== -1 && end === -1) {
} else if (code === 0x3d/* '=' */ && start !== -1 && end === -1) {
paramName = header.slice(start, i);

@@ -110,0 +110,0 @@ start = end = -1;

@@ -335,5 +335,15 @@ 'use strict';

perMessageDeflate.compress(data, options.fin, (_, buf) => {
this._deflating = false;
if (!this._socket.readable && !this._socket.writable) {
//
// The socket is closed. Clear the queue and bail out.
//
this._bufferedBytes = 0;
this._queue.length = 0;
return;
}
options.readOnly = false;
this.sendFrame(Sender.frame(buf, options), cb);
this._deflating = false;
this.dequeue();

@@ -340,0 +350,0 @@ });

@@ -6,3 +6,2 @@ 'use strict';

const http = require('http');
const url = require('url');

@@ -151,4 +150,7 @@ const PerMessageDeflate = require('./permessage-deflate');

shouldHandle (req) {
if (this.options.path && url.parse(req.url).pathname !== this.options.path) {
return false;
if (this.options.path) {
const index = req.url.indexOf('?');
const pathname = index !== -1 ? req.url.slice(0, index) : req.url;
if (pathname !== this.options.path) return false;
}

@@ -155,0 +157,0 @@

@@ -9,3 +9,3 @@ 'use strict';

const tls = require('tls');
const url = require('url');
const { URL } = require('url');

@@ -451,3 +451,3 @@ const PerMessageDeflate = require('./permessage-deflate');

} else {
parsedUrl = url.parse(address);
parsedUrl = new URL(address);
this.url = address;

@@ -454,0 +454,0 @@ }

{
"name": "ws",
"version": "6.1.0",
"version": "6.1.1",
"description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js",

@@ -23,3 +23,3 @@ "keywords": [

"index.js",
"lib"
"lib/*.js"
],

@@ -35,14 +35,14 @@ "scripts": {

"devDependencies": {
"benchmark": "~2.1.2",
"benchmark": "~2.1.4",
"bufferutil": "~4.0.0",
"eslint": "~5.6.1",
"eslint": "~5.9.0",
"eslint-config-standard": "~12.0.0",
"eslint-plugin-import": "~2.14.0",
"eslint-plugin-node": "~7.0.0",
"eslint-plugin-promise": "~4.0.0",
"eslint-plugin-node": "~8.0.0",
"eslint-plugin-promise": "~4.0.1",
"eslint-plugin-standard": "~4.0.0",
"mocha": "~5.2.0",
"nyc": "~13.0.1",
"nyc": "~13.1.0",
"utf-8-validate": "~5.0.0"
}
}

@@ -115,3 +115,2 @@ # ws: a Node.js WebSocket library

serverNoContextTakeover: true, // Defaults to negotiated value.
clientMaxWindowBits: 10, // Defaults to negotiated value.
serverMaxWindowBits: 10, // Defaults to negotiated value.

@@ -371,4 +370,2 @@ // Below options specified as default values.

const wss = new WebSocket.Server({ port: 8080 });
function noop() {}

@@ -380,2 +377,4 @@

const wss = new WebSocket.Server({ port: 8080 });
wss.on('connection', function connection(ws) {

@@ -399,2 +398,29 @@ ws.isAlive = true;

Just like the server example above your clients might as well lose connection
without knowing it. You might want to add a ping listener on your clients to
prevent that. A simple implementation would be:
```js
const WebSocket = require('ws');
function heartbeat() {
clearTimeout(this.pingTimeout);
// Use `WebSocket#terminate()` and not `WebSocket#close()`. Delay should be
// equal to the interval at which your server sends out pings plus a
// conservative assumption of the latency.
this.pingTimeout = setTimeout(() => {
this.terminate();
}, 30000 + 1000);
}
const client = new WebSocket('wss://echo.websocket.org/');
client.on('open', heartbeat);
client.on('ping', heartbeat);
client.on('close', function clear() {
clearTimeout(this.pingTimeout);
});
```
### How to connect via a proxy?

@@ -401,0 +427,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc