Commit Graph

209 Commits

Author SHA1 Message Date
Marko Žarković
cec27502f5 fix: correctly pass the options when using the Server constructor (#610)
Fixes https://github.com/socketio/engine.io/issues/580
2020-12-30 10:04:47 +01:00
Damien Arrachequesne
f5efa1e02a refactor: use ES6 syntax for the tests 2020-12-07 10:57:28 +01:00
Damien Arrachequesne
312bd356c7 ci: migrate to GitHub Actions
Due to the recent changes to the Travis CI platform (see [1]), we will
now use GitHub Actions to run the tests.

Reference: https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-nodejs

[1]: https://blog.travis-ci.com/2020-11-02-travis-ci-new-billing
2020-12-07 10:52:08 +01:00
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
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
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
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
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
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
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
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
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
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
JinHyuk Kim
6a16ea1192 [test] Remove unnecessary assertion in test case (#556) 2018-04-30 07:39:40 +02: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
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
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
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
Damien Arrachequesne
fd20b91208 [test] Use npm scripts instead of gulp (#530) 2017-09-01 14:21:57 +02:00
Damien Arrachequesne
e76e035873 [fix] Fix null payload when aborting connection (#503) 2017-04-28 13:46:50 +02:00
Damien Arrachequesne
82ed65f7c4 [test] Add test for maxHttpBufferSize option with websocket (#499) 2017-04-27 23:40:38 +02:00
Damien Arrachequesne
b436ca3887 [chore] Drop support for old nodejs versions (0.10 & 0.12) (#493) 2017-03-11 09:41:48 +01:00
Damien Arrachequesne
81ef0bc939 [feat] Add an option to toggle handling of OPTIONS requests (#491)
By setting `handlePreflightRequest` to false, OPTIONS request are no
longer processed by engine.io. A function can also be provided.
2017-03-11 09:04:00 +01:00
Luigi Pinca
cdb487dbdc [fix] Initialize the WebSocket server in the Server constructor (#476) 2017-01-30 15:52:00 +01:00
Damien Arrachequesne
274efa120e [feature] Add an initialPacket option (#471) 2017-01-22 07:51:27 +01:00
Damien Arrachequesne
f72f6f3fa6 [fix] allowRequest failures now return 403 Forbidden (#452) 2016-12-22 08:41:51 +01:00
Jérémy Lal
e144dc17ad [test] Fix test failure by increasing pingTimeout (#461) 2016-12-12 22:02:54 +01:00
Damien Arrachequesne
dd854a8803 [test] Use explicit versions for travis tests (#457) 2016-12-08 01:06:14 +01:00
Damien Arrachequesne
b5292c7826 [refactor] Remove deprecated code used for nodejs v0.8 (#456) 2016-12-08 01:01:10 +01:00
Julian Grinblat
7f659a50d3 [fix] Don't delete ws when closing the server (#444) 2016-11-15 22:01:20 +01:00
dlimkin
60780e2fb7 [feature] Fix cookiePath empty bug and add cookieHttpOnly option (#423) 2016-11-03 01:29:40 +01:00
Damien Arrachequesne
7c33b42153 [test] fix tests for NodeJS v7 (#441) 2016-11-03 01:28:01 +01:00
Diga Widyaprana
7cbdd5e5d9 [style] Add ESlint (#385) 2016-10-31 02:40:58 +01:00
Kim Min-Ho
e008ffeba5 [style] Fix some typos (#439) 2016-10-25 00:58:01 +02:00
Jérémy Lal
0d1f487696 Tests: disable SSL with uws tests on node < 4.4.3 2016-05-07 16:18:59 +02:00
Jérémy Lal
0b9d6dc496 Do not run tests with uws engine on Node < 4 2016-05-07 00:56:14 +02:00
Jérémy Lal
41165e0f15 Test if wsEngine option loads uws instead of ws 2016-05-07 00:38:02 +02:00
nkzawa
1a98563898 add tests for graceful close 2016-01-21 20:35:11 +09:00
Guillermo Rauch
22ebac4860 fix tests for 0.8 2015-12-01 11:41:49 -08:00
nkzawa
78b287742d improve X-XSS-Protection header definition 2015-12-01 23:03:44 +09:00
nkzawa
b56603169a add threshold for permessage-deflate 2015-12-01 14:21:53 +09:00
Damien Arrachequesne
cf9b0298a1 Add hasOwnProperty checks 2015-11-23 15:13:19 +01:00
Guillermo Rauch
057f32d195 Merge pull request #318 from amiuhle/cookie-path
Cookie path
2015-11-21 10:47:26 -08:00
Guillermo Rauch
b79830edd7 Merge pull request #348 from nkzawa/patch-7
Fix polling transports and add tests for closing transports
2015-11-18 10:41:15 -08:00
nkzawa
ce835c3b22 renew certs to extend expiration date 2015-11-19 02:46:44 +09:00
nkzawa
d74b3c7277 Merge branch 'master' into patch-7 2015-09-30 02:36:25 +09:00