ZeroMQ in javascript client

后端 未结 3 2070
轻奢々
轻奢々 2021-01-31 22:09

Have anyone used ZmqSocket.js successfully? I\'d like to know how can it be used to establish a safe channel between the browser and a zeromq server app. Is there other/better o

3条回答
  •  星月不相逢
    2021-01-31 22:31

    Another perspective: implementing a WebSocket-to-ZeroMQ proxy that handles all of ZeroMQ's strategies seems like a lot of work, but you can very quickly get a partial proxy running. Like Emil, I'm experimenting with a PyZMQ <--Tornado--> WebSocket bridge; in my case I only care about getting messages from SUB sockets.

    In my model, I send JSON messages from the browser to the proxy, requesting the creating of new ZMQ sockets. When these sockets receive data, they send it back to the browser over the same WebSocket connection.

    Here's the python proxy backend, and my javascript proxy frontend. In my Python code, the AsyncReciever class is a very thin wrapper around a ZMQStream that basically runs JSON encode/decode. If you want to send raw ZeroMQ bytes to the browser, things would be even easier: just connect a ZMQSocket.on_message callback directly to BridgeWebSocket.write_message.

提交回复
热议问题