[nanomsg] ws transport

  • From: Martin Sustrik <sustrik@xxxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Wed, 26 Nov 2014 13:06:25 +0100

Hi Jack,

I've spent few last days playing with the WebSocket transport. Here are some observations:

1. As already discussed there's a lot of stuff that's not really needed.
2. I've made an equivalent of tcp tests for ws and they fail.
3. When sending a message from client, the message body is masked. Given that message may be shared, this garbles the message daa for everyone else.

I've tried to make a minimal implementation of ws transport (see ws2 branch in the repo). It's still missing some pieces but good news is that all the tests (see ws.c and ws_shutdown.c) pass.

Here's the summary of how it works:

1. The connection string has the same format as tcp transport (host+port).
2. The "resource" field in the request is always set to "/"
3. Protocol field is always set to "sp"
4. After initial WebSocket handshake, each peer sends an 8-byte SP header as a new WebSocket message. Its format is the same as in tcp transport (see the RFC).

Missing pieces:

1. Timeout for the intial handshake.
2. Closing handshake
3. Rigorous validation of initial request and reply
4. Detailed error handling
5. Ping/pong

Thoughts?
Martin


Other related posts: