websocket._exceptions.WebSocketBadStatusException: Handshake status 429 Too Many Requests

Traceback (most recent call last):
  File "D:/spider_telegram/spider_17_deribit/spider_2_get_content.py", line 213, in <module>
    hour_spider(item)
  File "D:/spider_telegram/spider_17_deribit/spider_2_get_content.py", line 168, in hour_spider
    ws = websocket.create_connection(url=url, headers=headers)
  File "C:\Python37\lib\site-packages\websocket\_core.py", line 595, in create_connection
    websock.connect(url, **options)
  File "C:\Python37\lib\site-packages\websocket\_core.py", line 252, in connect
    self.handshake_response = handshake(self.sock, *addrs, **options)
  File "C:\Python37\lib\site-packages\websocket\_handshake.py", line 59, in handshake
    status, resp = _get_resp_headers(sock)
  File "C:\Python37\lib\site-packages\websocket\_handshake.py", line 145, in _get_resp_headers
    raise WebSocketBadStatusException("Handshake status %d %s", status, status_message, resp_headers)
websocket._exceptions.WebSocketBadStatusException: Handshake status 429 Too Many Requests

 

查看代码,忘记关闭链接了,加上ws.close() 即可

  

            url = 'wss://test.deribit.com/ws/api/v2'
            ws = websocket.create_connection(url=url, headers=headers)
            ws.send(json.dumps(msg))
            response = ws.recv()
            # ws.close()    

 

posted @ 2021-06-22 16:25  淋哥  阅读(1239)  评论(0编辑  收藏  举报