requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

mb12
Get this error sometimes when calling historical_data() function and if we look further the trace appears to be from:
Traceback (most recent call last):
File "/home/ubuntu/padantra/uenv/lib/python3.10/site-packages/requests/models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

It seems the following call kiteconnect/connect.py->_request() is giving the exception:
r = self.reqsession.request(...)

Which essentially means that the response from the kiteconnect API Server is sometimes non-json as well where as json is expected for the parsing! Can this be looked into?

Please note that this occurs when multiple calls are being made to historical_data() from multiple processes & many number of times! So it's even possible it may be going over the api rate limit across processes, not sure if that's the cause as there's a different error that i get when it crosses rate limit.
  • tonystark
    Could you enable the debug logs as per the getting started guide here? This will show what the API is actually responding with.
  • mb12
    problem is it comes once in a while, to get it i will have to keep debug off all the time that could slow the process down. but will try in some way where i can.
  • mb12
    *debug on
  • rakeshr
    requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
    It looks like an unhandled error at pykiteconnect. If you can paste the complete debug log, it will be helpful.
    You can also handle it at your end, by a failover retry.
Sign In or Register to comment.