zerodha / pykiteconnect

The official Python client library for the Kite Connect trading APIs
MIT License
965 stars 462 forks source link

ws.connect() failure #175

Closed vijaykz closed 1 year ago

vijaykz commented 1 year ago

Since last two days, ws.connect() has been failing. I found the error to be:

failing WebSocket connection (code=1000): "module 'log' has no attribute 'connect'"

I found ws.socket_url (below) value to be correct. Here is the log. Max retries are tried out, and every retry fails with above error.

2023-02-22 16:26:15.257588: socket_url: wss://ws.kite.trade?api_key=6063OVERWRITTENa1xp9&access_token=PArKJVdWcSOVERWRITTENXOpDZ8CI

2023-02-22 16:26:15+0530 [-] Log opened.
2023-02-22 16:26:15+0530 [-] failing WebSocket connection (code=1000): "module 'log' has no attribute 'connect'"
2023-02-22 16:26:15+0530 [-] dropping connection to peer tcp4:3.6.127.72:443 with abort=True: I dropped the WebSocket TCP connection: module 'log' has no attribute 'connect'
2023-02-22 16:26:15+0530 [-] <twisted.internet.tcp.Connector instance at 0x2821114df30 disconnected IPv4Address(type='TCP', host='ws.kite.trade', port=443)> will retry in 2 seconds
2023-02-22 16:26:15+0530 [-] Stopping factory <kiteconnect.ticker.KiteTickerClientFactory object at 0x000002821114E6B0>
2023-02-22 16:26:18+0530 [-] Starting factory <kiteconnect.ticker.KiteTickerClientFactory object at 0x000002821114E6B0>
2023-02-22 16:26:18+0530 [-] failing WebSocket connection (code=1000): "module 'log' has no attribute 'connect'"
2023-02-22 16:26:18+0530 [-] dropping connection to peer tcp4:3.6.127.72:443 with abort=True: I dropped the WebSocket TCP connection: module 'log' has no attribute 'connect'
2023-02-22 16:26:18+0530 [-] <twisted.internet.tcp.Connector instance at 0x2821114df30 disconnected IPv4Address(type='TCP', host='ws.kite.trade', port=443)> will retry in 5 seconds
2023-02-22 16:26:18+0530 [-] Stopping factory <kiteconnect.ticker.KiteTickerClientFactory object at 0x000002821114E6B0>

I am using Kiteconnect version 4.2.0. What could be the issue?

vijaykz commented 1 year ago

A local bug within on_connect() was causing connection failure. Since I didn't catch exception inon_connect(), I spent lot of time debugging.