Timeout error

D_coder
I am calling the KiteConnect methods inside an infinite loop with a time delay of 1 second. After 20 minutes or so I got the following error
Traceback (most recent call last):
File "C:\Users\hp\Anaconda3\lib\site-packages\urllib3\connection.py", line 159, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "C:\Users\hp\Anaconda3\lib\site-packages\urllib3\util\connection.py", line 80, in create_connection
raise err
File "C:\Users\hp\Anaconda3\lib\site-packages\urllib3\util\connection.py", line 70, in create_connection
sock.connect(sa)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\hp\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
chunked=chunked)
File "C:\Users\hp\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "C:\Users\hp\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 839, in _validate_conn
conn.connect()
File "C:\Users\hp\Anaconda3\lib\site-packages\urllib3\connection.py", line 301, in connect
conn = self._new_conn()
File "C:\Users\hp\Anaconda3\lib\site-packages\urllib3\connection.py", line 164, in _new_conn
(self.host, self.timeout))
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.VerifiedHTTPSConnection object at 0x000001484F155AC8>, 'Connection to api.kite.trade timed out. (connect timeout=7)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\hp\Anaconda3\lib\site-packages\requests\adapters.py", line 449, in send
timeout=timeout
File "C:\Users\hp\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Users\hp\Anaconda3\lib\site-packages\urllib3\util\retry.py", line 399, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.kite.trade', port=443): Max retries exceeded with url: /quote/ltp?i=408065&i=1850625&i=2953217&i=98049&i=3675137&i=3520257&i=582913&i=2905857 (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x000001484F155AC8>, 'Connection to api.kite.trade timed out. (connect timeout=7)'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/hp/Desktop/zero_final.py", line 514, in <module>
Nifty_SL()
File "C:/Users/hp/Desktop/zero_final.py", line 336, in Nifty_SL
ltp=kite.ltp(tokens_list)
File "C:\Users\hp\Anaconda3\lib\site-packages\kiteconnect\connect.py", line 599, in ltp
return self._get("market.quote.ltp", params={"i": ins})
File "C:\Users\hp\Anaconda3\lib\site-packages\kiteconnect\connect.py", line 822, in _get
return self._request(route, "GET", url_args=url_args, params=params, is_json=is_json)
File "C:\Users\hp\Anaconda3\lib\site-packages\kiteconnect\connect.py", line 873, in _request
raise e
File "C:\Users\hp\Anaconda3\lib\site-packages\kiteconnect\connect.py", line 870, in _request
proxies=self.proxies)
File "C:\Users\hp\Anaconda3\lib\site-packages\requests\api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\hp\Anaconda3\lib\site-packages\requests\sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\hp\Anaconda3\lib\site-packages\requests\sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "C:\Users\hp\Anaconda3\lib\site-packages\requests\adapters.py", line 504, in send
raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='api.kite.trade', port=443): Max retries exceeded with url: /quote/ltp?i=408065&i=1850625&i=2953217&i=98049&i=3675137&i=3520257&i=582913&i=2905857 (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x000001484F155AC8>, 'Connection to api.kite.trade timed out. (connect timeout=7)'))


Please advice
Sign In or Register to comment.