using sleep in on_ticks - getting "ERROR Connection error: 1006 - ..."

I am using the below code to insert tick to DB. every 3 sec and then sleep. I keep getting

2020-08-20 09:25:58,125 kiteconnect.ticker: ERROR Connection error: 1006 - connection was closed uncleanly (None)

def on_ticks(ws, ticks):
# Callback to receive ticks.

# process the tick and insert into DB


def on_close(ws, code, reason):
now =
marketclosetime = now.replace(hour=15, minute=30, second=0, microsecond=0)
if now > marketclosetime:
Sign In or Register to comment.