I am trying to use ZMQ to connect many publishers to one subscriber (python). This is one such publisher (I use connect instead of bind because the subscriber binds). The code works fine until I unblock the commented code below.
I then receive this error on Windows:
LoadError: StateError("Unknown error")
On Ubuntu:
StateError("Socket operation on non-socket")
Source code:
using ZMQ
using WebSockets
using JSON3
const uri = "wss://ws.okex.com:8443/ws/v5/public"
function produce_string()
return "hi"
end
function main()
payload = Dict(
:op => "subscribe",
:args => [
Dict(
"channel" => "books50-l2-tbt",
"instType" => "Futures",
"instId" => "FIL-USD-220325",
),
],
)
# Unblock this code to produce error
# @async while true
# WebSockets.open(uri) do ws
# confirmation = true
# if isopen(ws)
# write(ws, JSON3.write(payload))
# end
# end
# end
ctx = Context()
zmq_socket = Socket(ctx, PUB)
addr = "tcp://localhost:" * string(8093)
ZMQ.connect(zmq_socket, addr)
sleep(3)
ZMQ.send(zmq_socket, "hi")
while true
my_string = produce_string()
ZMQ.send(zmq_socket, my_string)
println("sent")
sleep(1)
end
end
main()