我现在尝试使用 Binance market stream 包连接到 WebSockets.jl,但没有得到任何响应。 我已经在这里查看并找到了 this question,但这会导致与所描述的相同的问题:收件箱频道只是在等待,但没有得到响应。
我试过的代码如下:
using WebSockets, JSON
uri = "wss://stream.binance.com:9443"
json_part = "{'method': 'SUBSCRIBE', 'params': ['btcusdt@depth'], 'id': 1}"
inbox = Channel{String}(10)
outbox = Channel{String}(10)
ws_task = @async WebSockets.open(uri) do 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
put!(outbox, json_part)
take!(inbox)
我以前从未使用过 WebSockets,所以可能我只是使用了错误的端点或请求格式。但我找不到更好的文档或有用的示例。
有人可以帮我让它工作吗?