mirror of
https://github.com/codex-storage/nim-websock.git
synced 2025-02-02 05:44:53 +00: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>
Websocket for Nim
This is an implementation of Websocket protocol for Nim and chronos.
nim-websock
includes both client and server in regular ws and wss(secure) mode.
It also pass all autobahn tests Autobahn summary report.
Building and testing
Install dependencies:
nimble install -d
Starting HTTP server:
nim c -r examples/server.nim
Testing Server Response:
curl --location --request GET 'http://localhost:8888'
Testing Websocket Handshake:
curl --include \
--no-buffer \
--header "Connection: Upgrade" \
--header "Upgrade: websocket" \
--header "Host: example.com:80" \
--header "Origin: http://example.com:80" \
--header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
--header "Sec-WebSocket-Version: 13" \
http://localhost:8888/ws
Roadmap
- Framing
- Text Messages
- Binary Messages
- Pings/Pongs
- Reserved Bits
- Opcodes
- Non-control Opcodes
- Control Opcodes
- Fragmentation
- UTF-8 Handling
- Close Handling
- Basic close behavior
- Close frame structure
- Payload length
- Valid close codes
- Invalid close codes
- Integrate Autobahn Test suite.
- WebSocket Compression
- WebSocket Extensions
- Performance
Description
Languages
Nim
100%