Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocket transport progress #3581

Open
16 of 27 tasks
somdoron opened this issue Jul 15, 2019 · 17 comments
Open
16 of 27 tasks

WebSocket transport progress #3581

somdoron opened this issue Jul 15, 2019 · 17 comments

Comments

@somdoron
Copy link
Member

somdoron commented Jul 15, 2019

  • draft ZWS 2.0 rfc https://github.com/zeromq/rfc/blob/master/45/README.md
  • WS address should allow path
  • Send correct hostname from client to server
  • use Sec-WebSocket-Protocol to negotiate protocol version and mechanism
  • Validate Sec-WebSocket-Accept
  • support websocket ping-pong
  • support websocket close command and closing handshake
  • Check validity of TLS certificates when set with setsockopt
  • 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.
  • use NULL mechanism
  • support zap and plain mechanism
  • encoder should encode other message types, not only binary (ping/pong/close)
  • Improve masking, as now it is creating a new buffer and copy it over
  • Remove duplicate code from ws_connecter and ws_listener.
  • TLS support
  • Make ws transport conditional at build time
  • Test all message sizes
  • use a timer for the handshake
  • Native javascript library implementing the protocol https://github.com/zeromq/jszmq
@jean-airoldie
Copy link
Contributor

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
Copy link
Member Author

somdoron commented Jul 23, 2019

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
Copy link
Contributor

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
Copy link
Member Author

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
Copy link
Contributor

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

@wgaylord
Copy link

wgaylord commented Sep 3, 2019

Any news?

@somdoron
Copy link
Member Author

somdoron commented Sep 3, 2019

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
Copy link
Member Author

somdoron commented Sep 4, 2019

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

@somdoron
Copy link
Member Author

somdoron commented Sep 5, 2019

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

@somdoron
Copy link
Member Author

somdoron commented Oct 1, 2019

WebSocket over TLS (WSS) is implemented #3695

@somdoron
Copy link
Member Author

somdoron commented Oct 4, 2019

CURVE and PLAIN mechanisms now work with WS and WSS transports.
#3702

@sigiesec
Copy link
Member

sigiesec commented Sep 4, 2020

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

@somdoron
Copy link
Member Author

somdoron commented Sep 5, 2020

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
Copy link
Member

sigiesec commented Sep 5, 2020

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
Copy link
Member Author

somdoron commented Sep 5, 2020

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
Copy link
Member Author

somdoron commented Sep 5, 2020

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
Copy link

Elsaligi commented Dec 9, 2022

  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants