def connect_websocket(self, sess=None):
'''
Creates a WebSocket connection.
'''
assert self.method == 'GET'
if sess is None:
sess = aiohttp.ClientSession()
else:
assert isinstance(sess, aiohttp.ClientSession)
try:
ws = await sess.ws_connect(self.build_url(), headers=self.headers)
return sess, ws
except Exception as e:
msg = 'Request to the API endpoint has failed.\n' \
'Check your network connection and/or the server status.'
raise BackendClientError(msg) from e
评论列表
文章目录