aiohttp无法正确连接websocket

时间:2018-11-27 11:34:21

标签: websocket aiohttp

我想连接此网络套接字URL wss://kline.bw.com/websocket,当我使用websocket-client时,它正常工作

from websocket import create_connection
con = create_connection('wss://kline.bw.com/websocket')
con.send('{"dataType":"281_ENTRUST_ADD_BTC_USDT","dataSize":50,"action":"ADD"}')
data = con.recv()

但是当我使用aiohttp连接此websocket时,它会引发WSServerHandshakeError

async with aiohttp.ClientSession() as session:
    async with session.ws_connect("wss://kline.BW.com/websocket", ssl=False) as ws:
        await ws.send('{"dataType":"281_ENTRUST_ADD_BTC_USDT","dataSize":50,"action":"ADD"}')、
        async for msg in ws:
            print(msg)

以及如何解决此错误?

0 个答案:

没有答案