Commit Graph

17 Commits

Author SHA1 Message Date
andri lim 282773af69
Reduce compiler warnings when using new chronos (#149)
* Reduce compiler warnings when using new chronos

* chronos req

* Reduce more warnings
2024-01-22 19:08:17 +07:00
Etan Kissling f8ed9b40a5
replace `utils` module with direct `generate` calls (#148)
The `utils` module uses a convoluted mechanism for filling byte arrays
with random data. The `generate` function can be used directly, making
the `utils` module obsolete.
2023-07-24 22:38:21 +02:00
diegomrsantos 3696e3f3a5
Handle cancellation in close (#143)
* Handle cancellation in close

* Using a future instead of sleepAsync
2023-06-06 22:57:40 +02:00
Tanguy 4c5e225eeb
Remove recvMsg pre-allocation (#136) 2023-01-25 17:56:42 +01:00
Tanguy 691f069b20
Fix closing hangs (#131)
A peer can make us wait forever when closing a connection.
This PR instead tries to be nice and wait for him, but kills the connection after a while
2022-11-22 10:45:38 +01:00
Etan Kissling 7b2ed397d6
properly support concurrent message sending (#126)
`nim-websock` suffered from a number of issues that are being addressed:

1. Long messages > `frameSize` (default 1 MB) were split into fragments
   of `frameSize` each. However, when a concurrent message is sent, it
   may be interleaved among the fragments of an already-sending message.
   This is only allowed for control packets without a mux extension.

2. When the WebSocket session is closed, a msg may have been partially
   received. This partial frame was reported as a full message, without
   indication that the receiving was canceled. This behaviour is fixed
   by raising a `WSClosedError` instead of reporting the partial msg.

3. When an individual `send` operation was canceled, it would actually
   stop sending the remainder of a potentially partially sent messages.
   This would corrupt the stream for concurrent and followup operations.
   Cancellation is now inhibited for the message currently sending.
   It is still possible to cancel messages that are not yet scheduled.

4. Messages could get reordered when using asynchronous encoders. This
   is addressed by delaying followup messages until the current message
   is fully encoded and transmitted (except for control packets).

Co-authored-by: Tanguy <tanguy@status.im>
2022-09-06 11:09:21 +02:00
tersec 8a72c0f769
--styleCheck:error (#122)
* --styleCheck:error

* --styleCheck:error iff >= Nim 1.6
2022-07-21 15:38:13 +00:00
Dustin Brody 47ceac54c2
stylecheck: payLoad -> payload 2022-07-05 17:02:05 +00:00
Tanguy 92d350fe88
Fix fragmented message sending (#116)
We previously crashed when sending things over 1mb
2022-06-30 17:14:07 +02:00
Tanguy 47b486b52f
Fix: handle simultaneous closing properly (#112)
Since we use readFrame instead of readMsg, we need to handle
it's possible exceptions. Closes #111
2022-05-25 16:02:46 +02:00
Tanguy 8927db93f6
Read frames instead of messages on close
Since #109, there can be only one concurrent user
of recvMsg. So in case someone is already reading,
better to readFrames
2022-05-19 14:27:44 +02:00
Tanguy edfbb169c8
Fix some issues with recv hanging (#109)
* Crash on concurrent reads
* Fix some issues with recv hanging
2022-05-18 14:37:53 +02:00
Jacek Sieka 14d852e0d4
style fixes (#108) 2022-04-08 11:11:53 +02:00
Tanguy 908632aa07
Fix for styleCheck:usages (#96) 2021-12-27 11:27:21 +01:00
Dmitriy Ryajov 0ec755738c
Perform utf-8 validation at message boundaries (#90)
* validate utf8 at the message level

* move utf-8 validation to message

* rename `recv` to `recvMsg`

* add partial frame validation tests

* use `recvMsg` instead of `recv`
2021-08-04 10:23:56 -06:00
Tanguy Cizain fec0f2bac1
add websock topic (#83) 2021-07-14 11:26:46 -06:00
jangko b3c60bbd4e
rename nim-ws to nim-websock 2021-06-29 08:50:29 +07:00