libzmq icon indicating copy to clipboard operation
libzmq copied to clipboard

WebSocket transport progress

Open somdoron opened this issue 5 years ago • 17 comments

  • [x] draft ZWS 2.0 rfc https://github.com/zeromq/rfc/blob/master/45/README.md
  • [x] WS address should allow path
  • [x] Send correct hostname from client to server
  • [x] use Sec-WebSocket-Protocol to negotiate protocol version and mechanism
  • [ ] Validate Sec-WebSocket-Accept
  • [x] support websocket ping-pong
  • [x] support websocket close command and closing handshake
  • [ ] Check validity of TLS certificates when set with setsockopt
  • [x] Support TLS with CMake
  • [ ] Initiate close handshake (server only?) RFC close handshake
  • [ ] Implement mechanisms in JSZMQ
  • [ ] Test multipart
  • [ ] Test all patterns
  • [ ] document the transport
  • [ ] document the WSS (TLS) transport
  • [ ] support http multiline header
  • [ ] Improve masking by masking 4 at a time with an integer.
  • [x] use NULL mechanism
  • [x] support zap and plain mechanism
  • [x] encoder should encode other message types, not only binary (ping/pong/close)
  • [x] Improve masking, as now it is creating a new buffer and copy it over
  • [ ] Remove duplicate code from ws_connecter and ws_listener.
  • [x] TLS support
  • [x] Make ws transport conditional at build time
  • [x] Test all message sizes
  • [x] use a timer for the handshake
  • [x] Native javascript library implementing the protocol https://github.com/zeromq/jszmq

somdoron avatar Jul 15 '19 07:07 somdoron

I have question regarding the websocket transport design.

Some websocket servers require a client to send a binary payload to subscribe to a channel or create an authenticated session. This payload is application specific and must be provided by the user. Moreover, since this payload might contain a nonce, it might change every time it is needed (so it can't be simply cached).

If restarting the websocket is done behind the curtain by zeromq (like for the other transports), there should be a way for the socket to get this user provided payload (or payloads) every time the socket is restarted. Maybe a function pointer would do the trick?

jean-airoldie avatar Jul 23 '19 03:07 jean-airoldie

My plan is to use the mechanism framework for that, initially I will support the plain mechanism which include a user and a password. Later I plan to add bearer mechanism. With mechanism each message include metadata of the sender. And you authenticate each new client using the ZAP protocol.

somdoron avatar Jul 23 '19 04:07 somdoron

I'm not following. Authentication on websockets is kind of the wild west. Each API as its own way of authenticating. How could ZAP be adapted for these abitrary mechanism?

jean-airoldie avatar Jul 23 '19 04:07 jean-airoldie

The websocket transport is not general. It is specific to zeromq, for example the more flag is encoded as the first byte of every message. I'm working on the javascript side of it, it will be ready in few days. So only a client that will implement the ZWS protocol (which is not documented yet) will be able to communicate with zeromq on top of the websocket transport.

As part of the protocol NULL & Plain mechanism are going to be used and later bearer mechanism.

somdoron avatar Jul 23 '19 05:07 somdoron

Gotcha, I though it was more a general purpose transport. If you also control the remote websocket it makes sense to use ZAP.

jean-airoldie avatar Jul 23 '19 05:07 jean-airoldie

Any news?

wgaylord avatar Sep 03 '19 13:09 wgaylord

I will push to github the pure javascript library today. At the point, you will be able to use it if you compile from source. I believe the underlying wire protocol won't change or will have backward support, so you will be able to use it.

somdoron avatar Sep 03 '19 13:09 somdoron

Javascript zeromq port that can communicate with libzmq over WS transport:https://github.com/somdoron/jszmq

somdoron avatar Sep 04 '19 11:09 somdoron

First draft of the protocol is ready: https://github.com/zeromq/rfc/blob/master/45/README.md

somdoron avatar Sep 05 '19 08:09 somdoron

WebSocket over TLS (WSS) is implemented #3695

somdoron avatar Oct 01 '19 20:10 somdoron

CURVE and PLAIN mechanisms now work with WS and WSS transports. https://github.com/zeromq/libzmq/pull/3702

somdoron avatar Oct 04 '19 14:10 somdoron

There are no tests for a websocket close command right now. Would that be feasible?

sigiesec avatar Sep 04 '20 15:09 sigiesec

There are no tests for a websocket close command right now. Would that be feasible?

Yes. The close workflow is implemented, so testing should be feasible.

somdoron avatar Sep 05 '20 06:09 somdoron

There are no tests for a websocket close command right now. Would that be feasible?

Yes. The close workflow is implemented, so testing should be feasible.

I just noticed that yesterday, when I extended the test coverage job to include some more transports. I have however not seen a way to produce a close message from the libzmq code, I just found code that reacts to receiving such a message, so I wondered how that could be tested :)

sigiesec avatar Sep 05 '20 11:09 sigiesec

There are no tests for a websocket close command right now. Would that be feasible?

Yes. The close workflow is implemented, so testing should be feasible.

I just noticed that yesterday, when I extended the test coverage job to include some more transports. I have however not seen a way to produce a close message from the libzmq code, I just found code that reacts to receiving such a message, so I wondered how that could be tested :)

I guess we should implement initiation of the close handshake as well? We can do so on the unplug method and delay the termination a bit (with a timeout timer).

somdoron avatar Sep 05 '20 11:09 somdoron

The close handshake from the rfc: https://tools.ietf.org/html/rfc6455#section-7

I've also added this as a checkbox item to the above list

somdoron avatar Sep 05 '20 11:09 somdoron

  • Sec-WebSocket-Protocol to negotiate protocol version and mechanism

Hi, Is there any example for wss libzmq transport in python please. It will be great. I was struggle for more than 1 week for secure websocket

Elsaligi avatar Dec 09 '22 16:12 Elsaligi