I keep getting these two messages every minute or two Connection error: 1006 - connection was closed uncleanly (None) Connection closed: 1006 - connection was closed uncleanly (None) this only started happening once I moved to kite3. Could you let me know the reason for this?
def on_ticks(ws, ticks): topic.publish(pickle.dumps(ticks)) for ticker in ticks: pickled_object = pickle.dumps(ticker) redisconn.lpush(str(ticker['instrument_token']),pickled_object) redisconn.set(getname(ticker['instrument_token']),pickled_object)
def on_connect(ws, response): logger.info("connected to ticker") ws.subscribe(tokens) ws.set_mode(ws.MODE_FULL,tokens)
def on_reconnect(ws, attempts_count): logger.info("attempting to reconnect to ticker")
def on_noreconnect(): logger.error("could not reconnect to to the ticker") sendSlackNotification("all attempts to reconnect to ticker have failed please check server","TickerSystem","process")
def on_close(ws, code, reason): logger.info("connection with ticker closed")
def on_error(ws, code, reason): logger.info("connection closed with ticker with error: " + str(reason))
@c00kie Dont see any issues here. Few qns. How are you invoking disconnectTicker? Can you use debug flag on kiteticker and post the logs? Why do you use pickle serialisation instead of json?
I am invoking disconnectTicker only when I close my process for the day, at the end of that day.
The reason I using pickle is because Kite is sending python date time objects for all day fields, and sending pickled objects across pubsub helps me create data frames for computation much easier .
I have tried making everything inside on_ticks async but that does not help and the disconnection is not on every tick. It happens exactly every 2-3 minutes. I thought my code was blocking It but that does not seem to be the case.
I will run code with the debug flag and post the log here.
The application is running on a vm so there shouldn't be any network problems. Also there were no problems like this on Friday last week, It only started once we moved to kite3.
I tried using the json serialization as specified by you, but it did not help.
Can you use debug flag on kiteticker and post the logs?
Why do you use pickle serialisation instead of json?
I will run code with the debug flag and post the log here.
These are the logs, its the same thing repeated again:
2018-05-15 12:02:48+0530 [-] dropping connection to peer tcp4:52.66.29.203:443 with abort=True: None
2018-05-15 12:02:48+0530 [-] Connection error: 1006 - connection was closed uncleanly (None)
2018-05-15 12:02:48+0530 [-] Connection closed: 1006 - connection was closed uncleanly (None)
2018-05-15 12:02:48+0530 [-] will retry in 2 seconds
2018-05-15 12:02:48+0530 [-] Stopping factory
2018-05-15 12:02:51+0530 [-] Starting factory
https://github.com/zerodhatech/pykiteconnect/blob/kite3/examples/ticker.py
You can add serializer for json.dumps using `default` param. See this