Unable to connect websocket(python)

Vinoth
Here is my debug log

2025-05-02 14:32:36+0530 [-] Log opened.
2025-05-02 14:32:57+0530 [Uninitialized] will retry in 2 seconds
2025-05-02 14:32:57+0530 [-] Stopping factory
2025-05-02 14:33:00+0530 [-] Starting factory
2025-05-02 14:33:21+0530 [-] Retrying connection. Retry attempt count: 1. Next retry in around: 3 seconds
2025-05-02 14:33:21+0530 [Uninitialized] will retry in 8 seconds
2025-05-02 14:33:21+0530 [-] Stopping factory
2025-05-02 14:33:29+0530 [-] Starting factory
2025-05-02 14:33:43+0530 [-] Received SIGINT, shutting down.
2025-05-02 14:33:43+0530 [-] Retrying connection. Retry attempt count: 2. Next retry in around: 8 seconds
2025-05-02 14:33:43+0530 [Uninitialized] will retry in 23 seconds
2025-05-02 14:33:43+0530 [-] Stopping factory
2025-05-02 14:33:43+0530 [-] Main loop terminated.

I have tried reassigned access token, checked my connection, my subscription validity nothing is worked. I don't know what error I'm receiving. Please someone help..

here is my code,

order_data = []

kws = KiteTicker(api_key=API_KEY, access_token=ACCESS)
# kite = KiteConnect(access_token=ACCESS, api_key=API_KEY)


dx = []

def on_ticks(ws,ticks):
ltp = [ticks[0]['last_price'],ticks[0]['volume_traded'],dt.now()]
dx.append(ltp)

print(ltp)



def on_connect(ws,response):
pass

def on_update(ws,data):
order_data.append(data)

kws.on_ticks = on_ticks
kws.on_connect = on_connect
kws.on_order_update = on_update
kws.debug = True

kws.connect(threaded=True, disable_ssl_verification=True)


def option():
while True:
try:
tkn_ = 227453701

kws.subscribe([tkn_])
kws.set_mode(kws.MODE_QUOTE, [tkn_])
time.sleep(0.5)
except Exception as e:
print(e)
pass


option()
  • Vinoth
    Here is my Log message,
    2025-05-02 14:32:36+0530 [-] Log opened.
    2025-05-02 14:32:57+0530 [Uninitialized] will retry in 2 seconds
    2025-05-02 14:32:57+0530 [-] Stopping factory
    2025-05-02 14:33:00+0530 [-] Starting factory
    2025-05-02 14:33:21+0530 [-] Retrying connection. Retry attempt count: 1. Next retry in around: 3 seconds
    2025-05-02 14:33:21+0530 [Uninitialized] will retry in 8 seconds
    2025-05-02 14:33:21+0530 [-] Stopping factory
    2025-05-02 14:33:29+0530 [-] Starting factory
    2025-05-02 14:33:43+0530 [-] Received SIGINT, shutting down.
    2025-05-02 14:33:43+0530 [-] Retrying connection. Retry attempt count: 2. Next retry in around: 8 seconds
    2025-05-02 14:33:43+0530 [Uninitialized] will retry in 23 seconds
    2025-05-02 14:33:43+0530 [-] Stopping factory
    2025-05-02 14:33:43+0530 [-] Main loop terminated.
  • Vinoth
    2025-05-02 14:32:57+0530 [Uninitialized] will retry in 2 seconds
  • sujith
    You shouldn't block the thread that is receiving ticks. You need to offload all tasks like doing calculations or writing to DB to another thread.
    You may refer to the pykiteconnect FAQs here.
Sign In or Register to comment.