Commit Graph

1192 Commits

Author SHA1 Message Date
Damien Arrachequesne
fe093bae1a fix: do not overwrite CORS headers upon error
The Access-Control-Allow-xxx headers added by the cors middleware were
overwritten when sending an error response.

Those lines should have been removed in [1].

[1]: 61b949259e

Related: https://github.com/socketio/engine.io/issues/605
2020-10-22 00:11:06 +02:00
Damien Arrachequesne
f9c0e74b14 chore: bump eiows to 3.3.2
The CI was failing with Node.js 14.13.0.
2020-10-05 01:04:17 +02:00
Damien Arrachequesne
a05379b1e8 test: use eiows
The eiows package is the published version of [1], which is a fork of
uws (a performant WebSocket server written in C++ with bindings for
Node.js).

[1] https://github.com/mmdevries/uws
2020-09-14 22:20:36 +02:00
Damien Arrachequesne
428b4f5200 docs: update links to other repositories 2020-09-14 22:04:49 +02:00
Damien Arrachequesne
ec83022ef4 docs: update examples with ES6 syntax 2020-09-14 22:00:40 +02:00
Damien Arrachequesne
609223959c docs: update latency example
The enchilada module fails to bundle the Engine.IO client, so we'll
just import the published bundle.

The exception seems to come from debug:

> Spread must be the final element of an element list
2020-09-11 02:40:28 +02:00
Damien Arrachequesne
70b1c36be1 chore(release): 4.0.0
Diff: https://github.com/socketio/engine.io/compare/v4.0.0-alpha.1...4.0.0
Full diff: https://github.com/socketio/engine.io/compare/3.4.0...4.0.0
2020-09-11 00:59:57 +02:00
Damien Arrachequesne
9df38d57fb docs: update the list of supported engines
As Node.js 8 is now EOL.
2020-09-10 15:52:32 +02:00
Damien Arrachequesne
078527a384 feat: disable perMessageDeflate by default
The WebSocket permessage-deflate extension, while useful is some cases,
adds some extra memory overhead for each WebSocket connection, and
results in huge memory usage in production deployments.

It will now be disabled by default.
2020-09-10 15:46:04 +02:00
Damien Arrachequesne
54c67978d5 docs: update the default value of maxHttpBufferSize
Following 734f9d1268
2020-09-10 15:22:43 +02:00
Damien Arrachequesne
1916d3ae62 test: remove Node.js 8 from the test matrix
Reference: https://github.com/nodejs/Release
2020-09-10 15:20:00 +02:00
Damien Arrachequesne
14ca7a1cfc chore: restore package-lock.json file
The package-lock.json file was removed in the previous commit, in order
to sync the client version when upgrading the parser (and make the
tests pass).
2020-09-09 02:09:44 +02:00
Damien Arrachequesne
ed29e5955d chore: bump engine.io-parser version
See also: https://github.com/socketio/engine.io-protocol#difference-between-v3-and-v4

Release: https://github.com/socketio/engine.io-parser/releases/tag/4.0.0
Diff: https://github.com/socketio/engine.io-parser/compare/2.2.0...4.0.0
2020-09-09 00:00:25 +02:00
Damien Arrachequesne
03b49674e6 chore: bump cookie version
Release: https://github.com/jshttp/cookie/releases/tag/v0.4.0
Diff: https://github.com/jshttp/cookie/compare/v0.3.1...v0.4.1
2020-09-08 02:47:18 +02:00
Damien Arrachequesne
09708eb307 docs(changelog): include changelog for release 3.4.2
Merged from the 3.4.x branch.
2020-06-04 16:23:05 +02:00
Damien Arrachequesne
82cdca23ba fix: remove implicit require of uws
So that bundlers like webpack do not try to include it in the build.

As a side-effect, any implementation which matches the API of the ws
module can now be used.

Before that change, you had to explicitly exclude uws:

```
// webpack.config.js
module.exports = {
  // ...
  externals: {
     uws: 'uws'
  }
};
```

Related: https://github.com/socketio/engine.io/issues/575
2020-06-04 14:24:42 +02:00
Damien Arrachequesne
94623c8f8b docs(changelog): include changelog for release 3.4.1
Merged from the 3.4.x branch.
2020-04-17 14:57:35 +02:00
Damien Arrachequesne
dcdbccb3dd fix: ignore errors when forcefully closing the socket (#601)
In order to catch the following errors:

```
events.js:288
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at afterWriteDispatched (internal/stream_base_commons.js:154:25)
    at writeGeneric (internal/stream_base_commons.js:145:3)
    at Socket._writeGeneric (net.js:780:11)
    at Socket._write (net.js:792:8)
    at doWrite (_stream_writable.js:441:12)
    at writeOrBuffer (_stream_writable.js:425:5)
    at Socket.Writable.write (_stream_writable.js:316:11)
    at abortConnection (<myproject>/node_modules/engine.io/lib/server.js:506:12)
    at <myproject>/node_modules/engine.io/lib/server.js:353:7
    at Server.verify (<myproject>/node_modules/engine.io/lib/server.js:158:14)
    at Server.handleUpgrade (<myproject>/node_modules/engine.io/lib/server.js:351:8)
```

Closes https://github.com/socketio/engine.io/issues/596, https://github.com/socketio/engine.io/pull/598
2020-04-15 11:42:31 +02:00
Damien Arrachequesne
71ece3ebf6 chore(release): 4.0.0-alpha.1 2020-02-12 08:33:47 +01:00
Damien Arrachequesne
b27215dcee chore(release): 4.0.0-alpha.0 2020-02-12 07:50:43 +01:00
Damien Arrachequesne
734f9d1268 feat: decrease the default value of maxHttpBufferSize
This change reduces the default value from 100 mb to a more sane 1 mb.

This helps protect the server against denial of service attacks by
malicious clients sending huge amounts of data.
2020-02-11 07:59:13 +01:00
Damien Arrachequesne
61b949259e feat: use the cors module to handle cross-origin requests
We'll now rely on the standard cors module (https://github.com/expressjs/cors),
instead of the custom implementation that is error-prone and not
really user-friendly.

Breaking change: the handlePreflightRequest option is removed by the
change.

Before:

```
new Server({
  handlePreflightRequest: (req, res) => {
    res.writeHead(200, {
      "Access-Control-Allow-Origin": 'https://example.com',
      "Access-Control-Allow-Methods": 'GET',
      "Access-Control-Allow-Headers": 'Authorization',
      "Access-Control-Allow-Credentials": true
    });
    res.end();
  }
})
```

After:

```
new Server({
  cors: {
    origin: "https://example.com",
    methods: ["GET"],
    allowedHeaders: ["Authorization"],
    credentials: true
  }
})
```
2020-02-11 07:54:25 +01:00
Damien Arrachequesne
bafe684a19 refactor: refactor the handling of the options 2020-02-10 12:07:41 +01:00
Damien Arrachequesne
61e639b257 test: add Node.js 10, 12 and 13 in the test matrix
uws is no longer maintained, and did not support Node.js >= 10.

We now use a fork in order to support the newer versions of Node.js.
It is maintained there: https://github.com/mmdevries/uws

And can be installed with: `npm i github:mmdevries/uws#2.4.1`

We could also try to support uWebSockets.js, but it does not have the
same API as ws.

The "engines" attribute has also been added in the package.json file,
since we broke the support for Node.js 6 in the latest minor release.

Source: https://github.com/mmdevries/uws
Related: https://github.com/socketio/engine.io/pull/583
2020-02-06 13:36:13 +01:00
Damien Arrachequesne
a374471d06 feat: disable cookie by default and add sameSite attribute
The cookie might be used for sticky-session, but is not mandatory so it
makes sense to disable it by default.

The change also add a SameSite=Lax attribute by default.

Breaking change: the syntax has changed from

```
new Server({
  cookieName: "test",
  cookieHttpOnly: false,
  cookiePath: "/custom"
})
```

to

```
new Server({
  cookie: {
    name: "test",
    httpOnly: false,
    path: "/custom"
  }
})
```

All other options (domain, maxAge, sameSite, ...) are now supported.

Reference: https://github.com/jshttp/cookie#options-1
2020-02-05 08:33:00 +01:00
Damien Arrachequesne
31ff87593f feat: reverse the ping-pong mechanism
The ping packets will now be sent by the server, because the timers set
in the browsers are not reliable enough. We suspect that a lot of
timeout problems came from timers being delayed on the client-side.

Breaking change: v3.x clients will not be able to connect anymore (they
will send a ping packet and timeout while waiting for a pong packet).

Related: https://github.com/socketio/engine.io/issues/312
2020-02-04 12:31:44 +01:00
Damien Arrachequesne
2ae2520a34 chore: point towards the v4 branch 2020-01-14 23:08:07 +01:00
Damien Arrachequesne
f3c291fa61 feat: generateId method can now return a Promise
Related:

- https://github.com/socketio/engine.io/issues/538
- https://github.com/socketio/engine.io/pull/535
2020-01-14 21:58:42 +01:00
Damien Arrachequesne
33564b2391 refactor: use prettier to format code 2020-01-14 21:58:38 +01:00
Damien Arrachequesne
da93fb6ef3 refactor: migrate to ES6 syntax 2020-01-12 22:47:18 +01:00
Damien Arrachequesne
ecfcc69a7a [chore] Release 3.4.0
Diff: https://github.com/socketio/engine.io/compare/3.3.2...3.4.0
2019-09-13 13:51:49 +02:00
Damien Arrachequesne
7bf75812c3 [chore] Bump engine.io-parser to version 2.2.0
Diff: https://github.com/socketio/engine.io-parser/compare/2.1.3...2.2.0
2019-09-13 13:46:43 +02:00
Yosi Attias
c471e03e09 [chore] Bump ws to latest version (#587) 2019-09-13 11:24:48 +02:00
Brian Kopp
c144895133 [feat] add additional debug messages (#586)
These additional messages will help more quickly diagnose the reason for error messages.
2019-09-13 11:21:37 +02:00
Dimitar Nestorov
a967626a1d [chore] Bump debug to version 4.1.0 (#581) 2019-09-13 11:19:02 +02:00
Damien Arrachequesne
5bbbfe2411 [ci] remove Node.js 4 and 6 from the build matrix
We keep Node.js 9 for compatibility with the 'uws' dependency (as Node.js 10 fails), but we'll
upgrade later.
2019-09-13 10:34:57 +02:00
Oliver Salzburg
ad844f4b32 [fix] Deprecated Buffer usage in dependency (#585)
The `Buffer` constructor has been deprecated in favor of safer alternatives.
See https://nodejs.org/en/docs/guides/buffer-constructor-deprecation/

This was fixed in base64id@2.0.0
2019-06-18 08:51:50 +02:00
Damien Arrachequesne
cb0ac6fddc [chore] Release 3.3.2 2018-11-29 22:51:12 +01:00
Damien Arrachequesne
ec4e12a063 [revert] Allow configuration of Access-Control-Allow-Origin value (#511)
This reverts commit ebf1a96f42.

Related: https://github.com/socketio/socket.io/issues/3381
2018-11-29 22:49:34 +01:00
Damien Arrachequesne
64d6044659 [chore] Release 3.3.1 2018-11-19 22:27:16 +01:00
Oliver Salzburg
9956445251 [fix] Replace deprecated Buffer usage (#565)
The `Buffer` constructor has been deprecated in favor of safer alternatives.
See https://nodejs.org/en/docs/guides/buffer-constructor-deprecation/
2018-11-19 22:22:13 +01:00
Damien Arrachequesne
e081616a3f [chore] Point towards branch 'develop' of engine.io-client 2018-11-19 22:15:19 +01:00
Damien Arrachequesne
2c856caf03 [chore] Release 3.3.0 2018-11-08 00:21:51 +01:00
Damien Arrachequesne
3e2f415f49 [chore] Bump ws to version 6.1.0 (#564) 2018-11-02 07:39:38 +01:00
Jacco Flenter
ebf1a96f42 [feat] Allow configuration of Access-Control-Allow-Origin value (#511)
It's now possible to specify an origins value (default value is '*') when initialising the engine. This value will be returned as the Access-Control-Allow-Origin value.

Related: #449
2018-11-02 07:38:16 +01:00
Damien Arrachequesne
0151c6a684 [chore] Release 3.2.1 2018-11-02 07:29:08 +01:00
shapel
bc7b2393de [fix] Processing error code on abort connection (#562)
Fixes #561
2018-11-02 07:25:53 +01:00
JinHyuk Kim
6a16ea1192 [test] Remove unnecessary assertion in test case (#556) 2018-04-30 07:39:40 +02:00
Damien Arrachequesne
d93ef6aeb9 [docs] Add some initialization examples in the README 2018-02-28 13:14:54 +01:00
Damien Arrachequesne
52ebe41832 [chore] Release 3.2.0 2018-02-28 01:31:24 +01:00