I would like to subscribe to some data feed using Websockets using Julia.
For example, from the linux terminal, I can successfully get data like this:
wscat -c wss://www.bitmex.com/realtime
{"op": "subscribe", "args": ["orderBookL2_25:XBTUSD"]}
Now in Julia, I cannot find a solution. I have tried the following, but it crashes Julia:
using WebSockets, JSON
uri = "wss://www.bitmex.com/realtime"
json_part = "{'op': 'subscribe', 'args': ['orderBookL2_25:XBTUSD']}"
inbox = Channel{String}(10)
outbox = Channel{String}(10)
ws_task = @async WebSockets.open(uri) do ws
while isopen(ws)
inbox_task = @async while !eof(ws)
put!(inbox, String(read(ws)))
end
outbox_task = @async while isopen(ws)
write(ws, take!(outbox))
end
end
end
# here Julia is crashing (hangs forever, I cannot get the cursor back)
put!(outbox, json_part)
take!(inbox)
Can someone help to get a working solution to subscribe to data feed using Julia?