followed all steps for resolving connection error 1006 but still getting error

harshtock
Hi,

I followed all steps mentioned in this thread, but still i am frequently getting connection error 1006.
My code is below:
kws = KiteTicker(api_key, access_token)

def on_ticks(ws, ticks):
logging.debug("Ticks: {}".format(ticks))

def on_connect(ws, response):
ws.subscribe(instrumentToken)
ws.set_mode(ws.MODE_FULL, instrumentToken)

kws.on_ticks = on_ticks
kws.on_connect = on_connect
# kws.on_close = on_close
kws.connect(threaded=True)

while True:
def on_ticks(ws, ticks):
tickOperations(ticks)

def tickOperations(ticks):
for tick in ticks:
print(tick)
return 'finished'

#Assign callback
kws.on_ticks=on_ticks
The error message is as follows:
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): sheets.googleapis.com:443
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "GET /v4/spreadsheets/SPREADSHEET?includeGridData=false HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "PUT /v4/spreadsheets/SPREADSHEET/values/%27cof%27%21A1%3AO1?valueInputOption=RAW HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "GET /v4/spreadsheets/SPREADSHEET?includeGridData=false HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "PUT /v4/spreadsheets/SPREADSHEET/values/%27cof%27%21A7032%3AO7032?valueInputOption=RAW HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "GET /v4/spreadsheets/SPREADSHEET?includeGridData=false HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "PUT /v4/spreadsheets/SPREADSHEET/values/%27cof%27%21A7033%3AO7033?valueInputOption=RAW HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "GET /v4/spreadsheets/SPREADSHEET?includeGridData=false HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "PUT /v4/spreadsheets/SPREADSHEET/values/%27cof%27%21A7034%3AO7034?valueInputOption=RAW HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "GET /v4/spreadsheets/SPREADSHEET?includeGridData=false HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "PUT /v4/spreadsheets/SPREADSHEET/values/%27cof%27%21A7035%3AO7035?valueInputOption=RAW HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "GET /v4/spreadsheets/SPREADSHEET?includeGridData=false HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "PUT /v4/spreadsheets/SPREADSHEET/values/%27cof%27%21A7036%3AO7036?valueInputOption=RAW HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "GET /v4/spreadsheets/SPREADSHEET?includeGridData=false HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "PUT /v4/spreadsheets/SPREADSHEET/values/%27cof%27%21A7037%3AO7037?valueInputOption=RAW HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "GET /v4/spreadsheets/SPREADSHEET?includeGridData=false HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "PUT /v4/spreadsheets/SPREADSHEET/values/%27cof%27%21A7038%3AO7038?valueInputOption=RAW HTTP/1.1" 200 None
ERROR:kiteconnect.ticker:Connection error: 1006 - connection was closed uncleanly (None)
ERROR:kiteconnect.ticker:Connection closed: 1006 - connection was closed uncleanly (None)
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "GET /v4/spreadsheets/SPREADSHEET?includeGridData=false HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "PUT /v4/spreadsheets/SPREADSHEET/values/%27cof%27%21A7039%3AO7039?valueInputOption=RAW HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "GET /v4/spreadsheets/SPREADSHEET?includeGridData=false HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "PUT /v4/spreadsheets/SPREADSHEET/values/%27cof%27%21A7040%3AO7040?valueInputOption=RAW HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "GET /v4/spreadsheets/SPREADSHEET?includeGridData=false HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "PUT /v4/spreadsheets/SPREADSHEET/values/%27cof%27%21A7041%3AO7041?valueInputOption=RAW HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "GET /v4/spreadsheets/SPREADSHEET?includeGridData=false HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "PUT /v4/spreadsheets/SPREADSHEET/values/%27cof%27%21A7042%3AO7042?valueInputOption=RAW HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "GET /v4/spreadsheets/SPREADSHEET?includeGridData=false HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "PUT /v4/spreadsheets/SPREADSHEET/values/%27cof%27%21A7043%3AO7043?valueInputOption=RAW HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "GET /v4/spreadsheets/SPREADSHEET?includeGridData=false HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "PUT /v4/spreadsheets/SPREADSHEET/values/%27cof%27%21A7044%3AO7044?valueInputOption=RAW HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "GET /v4/spreadsheets/SPREADSHEET?includeGridData=false HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "PUT /v4/spreadsheets/SPREADSHEET/values/%27cof%27%21A7045%3AO7045?valueInputOption=RAW HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "GET /v4/spreadsheets/SPREADSHEET?includeGridData=false HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "PUT /v4/spreadsheets/SPREADSHEET/values/%27cof%27%21A7046%3AO7046?valueInputOption=RAW HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "GET /v4/spreadsheets/SPREADSHEET?includeGridData=false HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://sheets.googleapis.com:443 "PUT /v4/spreadsheets/SPREADSHEET/values/%27cof%27%21A7047%3AO7047?valueInputOption=RAW HTTP/1.1" 200 None
ERROR:kiteconnect.ticker:Connection error: 1006 - connection was closed uncleanly (None)
ERROR:kiteconnect.ticker:Connection closed: 1006 - connection was closed uncleanly (None)

kindly advise.
  • rakeshr
    @harshtock
    We checked the above Websocket code at our end, it's working fine with no connection closure.
    "PUT /v4/spreadsheets/SPREADSHEET/....
    As seen from the above log, PUT operation seems to cause the closure. Can you re-check on Sheet APIs PUT operation part?
  • harshtock
    @rakeshr thanks for the response.. yes there could be an issue with sheet APIs due to read/write rate quotas. However, the main purpose of implementing the above is that any delay or issue in processing ticks won't affect/block the ticks on the main thread. Pl confirm if i need to implement queue for this. Or otherwise kindly confirm what i am missing.
  • rakeshr
    @harshtock
    You can implement queue and check.
Sign In or Register to comment.