Anthony
3f9ffc688f
[feature] Introduce the closeTimeout option ( #2308 )
...
Make graceful close timeout configurable.
2026-01-05 18:38:48 +01:00
yusheng chen
33f5dbaf33
[fix] Respond with the supported protocol versions ( #2291 )
...
Add the `Sec-WebSocket-Version` header, listing all supported versions,
to the response if the client requested version is either invalid or
unacceptable.
2025-06-28 15:00:23 +02:00
Luigi Pinca
021f7b8bff
[test] Shorten the path lengths
...
Shorten the length of temporary file and UNIX domain socket paths.
Refs: https://github.com/nodejs/node/pull/57005#issuecomment-2666921592
2025-02-20 15:43:05 +01:00
Luigi Pinca
e55e5106f1
[security] Fix crash when the Upgrade header cannot be read ( #2231 )
...
It is possible that the Upgrade header is correctly received and handled
(the `'upgrade'` event is emitted) without its value being returned to
the user. This can happen if the number of received headers exceed the
`server.maxHeadersCount` or `request.maxHeadersCount` threshold. In this
case `incomingMessage.headers.upgrade` may not be set.
Handle the case correctly and abort the handshake.
Fixes #2230
2024-06-16 11:42:59 +02:00
Luigi Pinca
01ba54edae
[feature] Introduce the autoPong option
...
Add the ability to disable the automatic sending of pong responses to
pings.
Fixes #2186
2023-12-26 16:30:22 +01:00
Luigi Pinca
c1d26c372e
[test] Fix failing test
2023-09-06 15:30:33 +02:00
Luigi Pinca
5b577fe665
[pkg] Remove native-duplexpair dev dependency
...
It seems to be no longer maintained.
2023-09-06 15:06:15 +02:00
Luigi Pinca
62521f26d7
[minor] Fix nits
2023-08-31 21:37:11 +02:00
Tim Perry
31da41728f
[fix] Make server.handleUpgrade() work with any duplex stream ( #2165 )
2023-08-31 21:09:31 +02:00
Luigi Pinca
5299b0ee6c
[test] Remove redundant tests
2023-08-20 11:13:46 +02:00
Luigi Pinca
e628f2bdb6
[feature] Support Windows named pipes ( #2079 )
...
Document how to connect to a named pipe endpoint and the limitations.
Refs: https://github.com/websockets/ws/pull/1808
Refs: https://github.com/websockets/ws/pull/2075
2022-09-22 22:16:59 +02:00
Luigi Pinca
0da60366f3
[test] Remove leftover from test
...
Refs: https://github.com/websockets/ws/commit/2995349f
2022-09-21 12:05:53 +02:00
Luigi Pinca
6e5a5ce341
[feature] Introduce the 'wsClientError' event ( #2046 )
...
Add the ability to inspect the invalid handshake requests and respond
to them with a custom HTTP response.
Closes #2045
2022-05-26 18:54:39 +02:00
Luigi Pinca
8889e48018
[test] Increase code coverage
2022-05-21 07:46:20 +02:00
Luigi Pinca
fb658bdd11
[minor] Use consistent error messages
...
Make some server error messages consistent with the respective client
error messages.
2022-05-21 07:25:52 +02:00
Luigi Pinca
e56cdfe1ec
[minor] Clarify why the handshake is aborted
...
Add more details about why the handshake is aborted in the HTTP
response.
Refs: https://github.com/websockets/ws/issues/2045#issuecomment-1130081274
2022-05-20 16:47:22 +02:00
Sergey Bakulin
e1ddacce06
[feature] Introduce the WebSocket option ( #2007 )
...
Add the ability to use a custom class that extends the `WebSocket`
class.
2022-02-01 20:25:02 +01:00
Luigi Pinca
abde9cfc21
[major] Call the callback with an error if the server is closed
...
Match the behavior of Node.js core `net.Server` and call the callback
of `WebSocketServer.prototype.close()` with an error if the server is
already closed.
2021-07-14 21:26:04 +02:00
Luigi Pinca
df7de574a0
[major] Do not close existing connections
...
When `WebSocketServer.prototype.close()` is called, stop accepting new
connections but do not close the existing ones.
If the HTTP/S server was created internally, then close it and emit the
`'close'` event when it closes. Otherwise, if client tracking is
enabled, then emit the `'close'` event when the number of connections
goes down to zero. Otherwise, emit it in the next tick.
Refs: https://github.com/websockets/ws/pull/1902
2021-07-14 21:26:04 +02:00
Luigi Pinca
e173423c18
[major] Do not decode Buffers to strings
...
Avoid decoding text messages and close reasons to strings. Pass them as
`Buffer`s to the listeners of their respective events. Also, make
listeners of the `'message'` event take a boolean argument to speficy
whether or not the message is binary.
Refs: https://github.com/websockets/ws/issues/1878
Refs: https://github.com/websockets/ws/issues/1804
2021-07-14 21:26:04 +02:00
Luigi Pinca
1877ddeb9f
[major] Validate the Sec-WebSocket-Protocol header
...
Abort the handshake if the `Sec-WebSocket-Protocol` header is invalid.
2021-07-14 21:26:04 +02:00
Luigi Pinca
772236a13f
[fix] Abort the handshake if the server is closing or closed
...
Prevent WebSocket connections from being established after
`WebSocketServer.prototype.close()` is called.
2021-07-09 12:47:58 +02:00
Luigi Pinca
5a58730480
[fix] Emit the 'close' event after the server is closed
...
Ensure that `WebSocketServer.prototype.close()` does not emit a
`'close'` event prematurely if called while the internal HTTP/S server
is closing.
2021-07-09 11:06:26 +02:00
Luigi Pinca
66e58d279f
[fix] Make the {noS,s}erver, and port options mutually exclusive
...
Remove ambiguity and prevent `WebSocketServer.prototype.address()` from
throwing an error if the `noServer` option is used along with the
`port` and/or `server` options.
2021-07-08 13:55:29 +02:00
Luigi Pinca
145480a5b5
[test] Fix repeated typo
2021-06-20 19:51:56 +02:00
Luigi Pinca
2079ca5e37
[test] Increase code coverage
2021-01-26 16:49:10 +01:00
Luigi Pinca
40a9d2aff0
[test] Fix typo
2020-08-06 07:42:37 +02:00
Luigi Pinca
9a99197698
[test] Clarify comment
2020-08-05 19:19:39 +02:00
Luigi Pinca
42abb0ef55
[test] Use os.tmpdir() instead of hardcoded /tmp
2020-08-05 17:10:09 +02:00
Luigi Pinca
88d0345997
[pkg] Update prettier to version 2.0.5
2020-06-13 08:51:03 +02:00
Luigi Pinca
62f71d1aa6
[minor] Throw an error on invalid method usage
...
Throw an error if `WebSocketServer.prototype.completeUpgrade()` is
called more than once with the same socket argument.
2020-04-22 07:32:24 +02:00
Luigi Pinca
79dfbcf9f2
[test] Move test to appropriate section
2020-04-22 07:32:24 +02:00
Luigi Pinca
06d866004e
Revert "[minor] Throw an error on invalid usage"
...
This reverts commit 364126620b .
2020-04-22 07:32:24 +02:00
Luigi Pinca
4f293a8726
[fix] Close the connection if the MASK bit is incorrectly set ( #1681 )
...
Follow the specification and close the connection when a non masked
frame is received on the server or a masked frame is received on the
client.
Refs: https://tools.ietf.org/html/rfc6455#section-5.1
Closes #1679
2020-01-21 21:03:22 +01:00
Luigi Pinca
364126620b
[minor] Throw an error on invalid usage
...
Throw an error if the same `server` option is used for multiple
WebSocket servers at the same time.
2019-07-14 14:41:28 +02:00
Luigi Pinca
148c37363a
[test] Prefer arrow functions
2019-03-17 07:49:47 +01:00
Luigi Pinca
855494da8d
[test] Fix flaky test
2019-03-02 15:21:50 +01:00
Luigi Pinca
160af45bf3
[fix] Abort the handshake if the Sec-WebSocket-Key header is invalid
2019-02-22 10:46:38 +01:00
Luigi Pinca
b9fad73f53
[lint] Use prettier
2018-11-17 09:39:58 +01:00
Luigi Pinca
cddbcf6667
[test] Remove unused variables
2018-10-29 21:56:17 +01:00
Luigi Pinca
90407bbf34
[feature] Make WebSocketServer#close() emit 'close' ( #1453 )
...
Fixes #1375
2018-10-04 07:51:34 +02:00
Dmitry Kirilyuk
d871bdfdc8
[feature] Add headers argument to verifyClient() callback ( #1379 )
...
Add ability to specify custom headers when rejecting the handshake.
2018-05-12 21:42:31 +02:00
Luigi Pinca
fb05059620
[test] Fix faulty test
2018-03-06 07:58:05 +01:00
Luigi Pinca
3f80ab717c
[major] Drop support for Node.js < 4.5.0 ( #1313 )
2018-03-04 13:36:53 +01:00
Luigi Pinca
14538dbf96
[major] Fix subprotocol handling ( #1312 )
...
Do not close the connection if the server does not agree to any of
the client's requested subprotocols.
Fixes #1296
2018-03-03 07:27:20 +01:00
Luigi Pinca
a70bd65485
[test] Fix typo
2018-02-22 08:54:42 +01:00
Luigi Pinca
563edbd6fa
[test] Use WebSocketServer#address()
2018-02-15 16:39:03 +01:00
Tossapon Nuanchuay
8d61fa057e
[api] Add WebSocketServer.prototype.address() ( #1294 )
2018-02-05 20:48:05 +01:00
Luigi Pinca
1c783c295c
[major] Rename the 'headers' event to 'upgrade'
...
Refs: https://github.com/websockets/ws/pull/1082#issuecomment-295755780
2018-01-05 10:01:51 +01:00
Luigi Pinca
9bbc978368
[test] Reorganize tests
2018-01-05 10:01:51 +01:00