FlightRadarAPI icon indicating copy to clipboard operation
FlightRadarAPI copied to clipboard

Timeout error

Open caro-acdm opened this issue 1 year ago • 2 comments

I am using this api in a python script in a try-except loop... ideally it should run indefinitely in cycles of 15-20 seconds. in each cycle, it is calling this api to get a bunch of flights a given bound. Usually it runs fine, but every now and then, it gives out a connection timeout error. Is anyone else facing the same problem? Also, can this problem be solved by getting a premium account?

This is the error log: Traceback (most recent call last): File "D:\Proj_Dxxxx\Lib\site-packages\urllib3\connection.py", line 198, in _new_conn sock = connection.create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Proj_Dxxxx\Lib\site-packages\urllib3\util\connection.py", line 85, in create_connection raise err File "D:\Proj_Dxxxx\Lib\site-packages\urllib3\util\connection.py", line 73, in create_connection sock.connect(sa) TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "D:\Proj_Dxxxx\Lib\site-packages\urllib3\connectionpool.py", line 793, in urlopen response = self._make_request( ^^^^^^^^^^^^^^^^^^^ File "D:\Proj_Dxxxx\Lib\site-packages\urllib3\connectionpool.py", line 491, in _make_request raise new_e File "D:\Proj_Dxxxx\Lib\site-packages\urllib3\connectionpool.py", line 467, in _make_request self._validate_conn(conn) File "D:\Proj_Dxxxx\Lib\site-packages\urllib3\connectionpool.py", line 1099, in _validate_conn conn.connect() File "D:\Proj_Dxxxx\Lib\site-packages\urllib3\connection.py", line 616, in connect self.sock = sock = self._new_conn() ^^^^^^^^^^^^^^^^ File "D:\Proj_Dxxxx\Lib\site-packages\urllib3\connection.py", line 207, in _new_conn raise ConnectTimeoutError( urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x000001A3590B6990>, 'Connection to data-cloud.flightradar24.com timed out. (connect timeout=None)')

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "D:\Proj_Dxxxx\Lib\site-packages\requests\adapters.py", line 486, in send resp = conn.urlopen( ^^^^^^^^^^^^^ File "D:\Proj_Dxxxx\Lib\site-packages\urllib3\connectionpool.py", line 847, in urlopen retries = retries.increment( ^^^^^^^^^^^^^^^^^^ File "D:\Proj_Dxxxx\Lib\site-packages\urllib3\util\retry.py", line 515, in increment raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='data-cloud.flightradar24.com', port=443): Max retries exceeded with url: /zones/fcgi/feed.js?faa=1&satellite=1&mlat=1&flarm=1&adsb=1&gnd=1&air=1&vehicles=1&estimated=1&maxage=14400&gliders=1&stats=1&limit=5000&bounds=21.235737033567297%2C16.90672529427908%2C70.61287068113106%2C75.19786605225617 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x000001A3590B6990>, 'Connection to data-cloud.flightradar24.com timed out. (connect timeout=None)'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "D:\Proj_Dxxxx\track_missing_flights\track_missing_flights.py", line 194, in fetch_and_append_ns_flights(fr_api) ^^^^^^ File "D:\Proj_Dxxx\track_missing_flights\track_missing_flights.py", line 190, in main

File "D:\Proj_Dxxx\track_missing_flights\track_missing_flights.py", line 27, in fetch_and_append_ns_flights flights = fr_api.get_flights(bounds=bounds) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Proj_Dxxx\Lib\site-packages\FlightRadar24\api.py", line 309, in get_flights response = APIRequest(Core.real_time_flight_tracker_data_url, request_params, Core.json_headers) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Proj_Dxxxx\Lib\site-packages\FlightRadar24\request.py", line 56, in init self.__response = request_method(url, headers=headers, cookies=cookies, data=data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Proj_Dxxxx\Lib\site-packages\requests\api.py", line 73, in get return request("get", url, params=params, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Proj_Dxxxx\Lib\site-packages\requests\api.py", line 59, in request return session.request(method=method, url=url, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Proj_Dxxxx\Lib\site-packages\requests\sessions.py", line 589, in request resp = self.send(prep, **send_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Proj_Dxxxx\Lib\site-packages\requests\sessions.py", line 703, in send r = adapter.send(request, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Proj_Dxxxx\Lib\site-packages\requests\adapters.py", line 507, in send raise ConnectTimeout(e, request=request) requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='data-cloud.flightradar24.com', port=443): Max retries exceeded with url: /zones/fcgi/feed.js?faa=1&satellite=1&mlat=1&flarm=1&adsb=1&gnd=1&air=1&vehicles=1&estimated=1&maxage=14400&gliders=1&stats=1&limit=5000&bounds=21.235737033567297%2C16.90672529427908%2C70.61287068113106%2C75.19786605225617 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x000002391081A780>, 'Connection to data-cloud.flightradar24.com timed out. (connect timeout=None)'))

caro-acdm avatar Apr 29 '24 09:04 caro-acdm

It is a connection problem on your network.

If you still have this problem, try inserting verify=False at this line. Let me know if it solves the problem.

It could even be your DNS resolver that is unable to resolve the FR's address.

JeanExtreme002 avatar Apr 30 '24 00:04 JeanExtreme002

I added verify=False as you said: self.__response = request_method(url, headers=headers, cookies=cookies, data=data, verify=False)

It didn't solve the problem.

I will look into my DNS resolver also.

On Tue, Apr 30, 2024 at 12:44 AM Jean Loui Bernard @.***> wrote:

It is a connection problem on your network.

If you still have this problem, try inserting verify=False at this line https://github.com/JeanExtreme002/FlightRadarAPI/blob/ac6479d15540a8b36d1e4407b783a596ac011634/python/FlightRadar24/request.py#L56. Let me know if it solves the problem.

It could even be your DNS resolver that is unable to resolve the FR's address.

— Reply to this email directly, view it on GitHub https://github.com/JeanExtreme002/FlightRadarAPI/issues/70#issuecomment-2083975688, or unsubscribe https://github.com/notifications/unsubscribe-auth/BIAZNIQH62ZJ3N625XE2LU3Y73SPFAVCNFSM6AAAAABG57TFLOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBTHE3TKNRYHA . You are receiving this because you authored the thread.Message ID: @.***>

caro-acdm avatar Apr 30 '24 04:04 caro-acdm

I'm closing this issue for now.

If you get any problem else using the project, feel free to open another issue.

Best regards, Jean

JeanExtreme002 avatar May 17 '24 22:05 JeanExtreme002