Commit Graph

1027 Commits

Author SHA1 Message Date
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
Damien Arrachequesne
c6247514e2 [revert] Make generateId method async (#535)
That is a breaking change, which mandates a major bump.
2018-02-27 22:03:49 +01:00
Damien Arrachequesne
be3833bddd [refactor] Use Buffer.concat([]) to construct an empty buffer (#555) 2018-02-27 22:03:31 +01:00
Damien Arrachequesne
65b1ad1b8a [chore] Update default values for pingTimeout (#551)
`pingTimeout` now defaults to 5 seconds instead of 60 seconds.
2018-02-27 22:03:16 +01:00
Damien Arrachequesne
63e2528656 [chore] Release 3.1.5
Cherry-picked from 3.1.x branch.
2018-02-18 11:47:19 +01:00
Damien Arrachequesne
b1fa020675 [chore] Revert to ws as default wsEngine (#550)
Related:
- https://github.com/socketio/socket.io/issues/2956
- https://github.com/socketio/socket.io/issues/3100

Fixes #536
Fixes #516
Fixes #474
2017-12-29 22:39:34 +01:00
Damien Arrachequesne
d50bf873a6 [chore] Bump dependencies (#549)
- debug to version 3.1.0
- babel-eslint to version 8.0.2
- mocha to version 4.0.1
- superagent to version 3.8.1
2017-12-28 23:30:04 +01:00
Andrew Nesbitt
3b0aef0c7b [chore] Bump accepts to version 1.3.4 (#548) 2017-12-27 22:52:58 +01:00
Andrew Nesbitt
7a3c267af2 [docs] Update test command in README (#547) 2017-12-27 22:51:35 +01:00
Damien Arrachequesne
112c304d7a [chore] Bump uws to version 9.14.0 (#545) 2017-11-22 22:10:05 +01:00
Nick Tazelaar
73e579a501 [refactor] Add some checks to prevent usage of undefined properties (#540) 2017-11-22 22:04:54 +01:00
Damien Arrachequesne
5308f1c3a0 [chore] Release 3.1.4 2017-11-22 22:00:55 +01:00
Luigi Pinca
3c59bed613 [chore] Bump ws to version 3.3.1 (#543)
Related: https://nodesecurity.io/advisories/550
2017-11-12 21:55:00 +01:00
efkan
2abb217e26 [feat] Make generateId method async (#535)
That change will allow to retrieve the client id asynchronously, from a database for example.
2017-10-20 08:00:29 +02:00
Damien Arrachequesne
3ee803af72 [chore] Release 3.1.3 2017-10-11 07:59:04 +02:00
Damien Arrachequesne
49362abcd0 [fix] Fix undefined remoteAddress when using uws (#533)
Fixes https://github.com/socketio/socket.io/issues/2982
2017-10-11 07:29:52 +02:00