Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time out? #34

Open
jasonpolstein opened this issue Feb 18, 2021 · 4 comments
Open

Time out? #34

jasonpolstein opened this issue Feb 18, 2021 · 4 comments

Comments

@jasonpolstein
Copy link

New to Finnhub. I am running the following simple code and getting an error message. What is causing this?

CODE
import finnhub
import time
import datetime
import pandas as pd

Setup client
finnhub_client = finnhub.Client(api_key="XXXXXXXXXXXXX")

Stock candles
res = finnhub_client.stock_candles('AAPL', 'D', 1590988249, 1591852249)
print(res)

ERROR MESSAGE
Traceback (most recent call last):
File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 426, in _make_request
six.raise_from(e, None)
File "", line 3, in raise_from
File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 421, in _make_request
httplib_response = conn.getresponse()
File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/http/client.py", line 1332, in getresponse
response.begin()
File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/http/client.py", line 303, in begin
version, status, reason = self._read_status()
File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/http/client.py", line 264, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 724, in urlopen
retries = retries.increment(
File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/urllib3/util/retry.py", line 403, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/urllib3/packages/six.py", line 735, in reraise
raise value
File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen
httplib_response = self._make_request(
File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 428, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 335, in _raise_timeout
raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='finnhub.io', port=443): Read timed out. (read timeout=10)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "timeout-test.py", line 11, in
res = finnhub_client.stock_candles('AAPL', 'D', 1590988249, 1591852249)
File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/finnhub/client.py", line 206, in stock_candles
return self._get("/stock/candle", params=params)
File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/finnhub/client.py", line 69, in _get
return self._request("get", path, **kwargs)
File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/finnhub/client.py", line 38, in _request
response = getattr(self._session, method)(uri, **kwargs)
File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/requests/sessions.py", line 543, in get
return self.request('GET', url, **kwargs)
File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/Users/jasonpolstein/opt/anaconda3/lib/python3.8/site-packages/requests/adapters.py", line 529, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='finnhub.io', port=443): Read timed out. (read timeout=10)

@dejoski
Copy link

dejoski commented Apr 20, 2021

I have same issue, finnhub_client.aggregate_indicator fails half of the time

@enoch-prince
Copy link

I have the same issue with pattern_recognition. Is there no way to increase the timeout value?

@KosherMeatBoy
Copy link

KosherMeatBoy commented Nov 17, 2021

@enoch-prince , @jasonpolstein , @dejoski
Just ran into the same issues. If you go into the Client class file (called client.py, in VSCode you can hold control and click on the Client class declaration wherever it is in your code to move to where that class is defined), change the DEFAULT_TIMEOUT value. Increased mine to 120 seconds. So far no issues.

EDIT: So now instead of a read timeout, I'm running into a 504: Gateway time-out from the API. Seems that Finnhub may not be able to keep up with API requests....
I've reached out to their support to identify the issues and see if they are working on something like scaling solutions.

Great service in theory but I may be moving onto different API until Finnhub can resolve these issues.

@ghost
Copy link

ghost commented Nov 23, 2023

I am still having the issues mentioned above. Has there been no fix for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants