zeromq / libzmq

ZeroMQ core engine in C++, implements ZMTP/3.1
https://www.zeromq.org
Mozilla Public License 2.0
9.7k stars 2.35k forks source link

WebSocket transport progress #3581

Open somdoron opened 5 years ago

somdoron commented 5 years ago
jean-airoldie commented 5 years ago

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?

somdoron commented 5 years ago

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.

jean-airoldie commented 5 years ago

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?

somdoron commented 5 years ago

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.

jean-airoldie commented 5 years ago

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

wgaylord commented 5 years ago

Any news?

somdoron commented 5 years ago

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 commented 5 years ago

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

somdoron commented 5 years ago

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

somdoron commented 5 years ago

WebSocket over TLS (WSS) is implemented #3695

somdoron commented 5 years ago

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

sigiesec commented 4 years ago

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

somdoron commented 4 years ago

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.

sigiesec commented 4 years ago

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 :)

somdoron commented 4 years ago

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 commented 4 years ago

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

Elsaligi commented 1 year ago
  • 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