I am trying to get ZeroMQ working in my web app. On the front end, I am using the JSZMQ library which is supposed to work in-browser (I am aware that most libraries do not). On the Python back end, I am using zmq. The problem is that all the protocols I try throw an error. If I try TCP, as expected the browser throws an error saying "unsupported transport".
According to this SO question JSZMQ should work when the protocol is "ws://". When I try this, the server throws a "Protocol not supported" error immediately on running it. Here is my code:
Client:
import * as zmq from 'jszmq'
const socket = new zmq.Pull()
socket.connect('ws://127.0.0.1:3000')
socket.on('message', msg => console.log(msg))
Server:
import zmq
context = zmq.Context()
sock = context.socket(zmq.PUSH)
sock.bind('ws://127.0.0.1:3000') # This is what throws the error
sock.send('hello')
If it matters I am doing multiprocessing for the server, with the zmq object as a global since it's not serializable and can't be passed into functions as an argument.
Why is this not working?