【发布时间】:2018-04-28 13:45:20
【问题描述】:
我已经建立了与多个加密货币交易所的 websocket 连接,但我在连接到 bitFlyer 时遇到了困难。
我的代码如下:
import websocket
import json
def on_message(ws, message):
msg = json.loads(message)
print(msg)
def on_error(ws, error):
print(error)
def on_close(ws):
print("### closed ###")
def on_open(ws):
ws.send(json.dumps({"method":"subscribe", "channel":"lightning_executions_FX_BTC_JPY"}))
while True:
if __name__ == "__main__":
#websocket.enableTrace(True)
ws = websocket.WebSocketApp("wss://ws.lightstream.bitflyer.com/json-rpc",
on_message=on_message,
on_error=on_error,
on_close=on_close)
ws.on_open = on_open
ws.run_forever()
我已经尝试了我的 on_open() 消息的许多变体,大多数都导致 ### closed ###
Invalid close opcode. 错误。
不幸的是,他们的文档不包含位于 HERE 的 Python 示例。
非常感谢您在发送正确消息方面的任何帮助。
【问题讨论】: