[nanomsg] WebSocket Transport design considerations

  • From: Jack Dunaway <jack@xxxxxxxxxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Thu, 9 Oct 2014 23:38:18 -0500

I have begun investigating development of a WebSocket transport for
nanomsg, and I'm curious what design/implementation/brainpower others have
put into this already.

The first stage "hack" in this investigation has been retrofitting the
existing TCP transport (
https://github.com/nanomsg/nanomsg/tree/master/src/transports/tcp) to
dispatch different handshake and send/recv handlers based on transport
scheme.

Based on a day's worth of hacking, here are a few early-stage design
considerations:

1a) It feels heavy-handed to copy-and-paste the entire TCP transport
wholesale, just to change a few key areas where WebSockets differ (e.g., on
the surface, only STCP needs non-trivial modification). On the other hand,
the IPC transport very closely resembles TCP, so perhaps there's merit in
this duplication? That said, does it make more sense to duplicate the TCP
protocol as a starting point for the WS protocol, or to extend the existing
TCP?

1b) As a corollary, any considerations/plans generally on pluggable wire
protocols? (i.e., different handshake sequence and send/recv headers)

2) There exist several WebSocket protocol parsing libraries in C; however,
I'm not readily finding a sweet spot of License + Quality + RFC 6455
coverage. Ideas?

3) Since the WebSocket protocol does not have a fixed-width header like the
nanomsg TCP wire-level protocol (
https://github.com/nanomsg/nanomsg/blob/master/rfc/sp-tcp-mapping-01.txt#L68),
this presents a fundamental new challenge buffering and parsing an incoming
stream. Thoughts?

4) For the ws:// protocol, how should a client negotiate scalability
protocol? Via parameters on the URI (e.g., ws://127.0.0.1:9876/?sp=NN_SUB)?
And, what shall be the value of Sec-WebSocket-Protocol?

5) Does it make sense to attack this problem of nanomsg<->WebSockets as a
specific application use-case, or as generally desirable transport
considered for inclusion into the core nanomsg library?

6) wss:// ... ?

Forgive my naïvete as a newcomer to nanomsg! Contact me directly to pair
program or for design discussion. (Previous research into this topic only
finds: //www.freelists.org/post/nanomsg/websocket-transport)

Best regards,

Jack R. Dunaway | Wirebird Labs LLC

Other related posts: