traffic icon indicating copy to clipboard operation
traffic copied to clipboard

Can't retrieve live state information from opensky

Open simonrp84 opened this issue 1 year ago • 2 comments

Hello! If I try to use the api_states call to retrieve live information from the opensky data via traffic then I get this error message:

Retrying in 10 seconds... {retry} more time
Retrying in 10 seconds... {retry} more time
Retrying in 10 seconds... {retry} more time
Retrying in 10 seconds... {retry} more time
Retrying in 10 seconds... {retry} more time
Client error '401 ' for url 'https://opensky-network.org/api/states/all'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
Retrying in 10 seconds... {retry} more time
Retrying in 10 seconds... {retry} more time
Retrying in 10 seconds... {retry} more time
Retrying in 10 seconds... {retry} more time
Retrying in 10 seconds... {retry} more time

And the states are not retrieved. My code is:

from traffic.data import opensky
sv = opensky.api_states()

This is not an issue with my machine being blocked by opensky as I can use curl https://opensky-network.org/api/states/all to successfully retrieve the states. I have added my login information to the traffic.conf file and have also tried without my credentials being in that file.

Any suggestions for what could be wrong?

If helpful, the debug info is:

DEBUG:httpcore.connection:close.started
DEBUG:httpcore.connection:close.complete
DEBUG:httpcore.connection:connect_tcp.started host='opensky-network.org' port=443 local_address=None timeout=5.0 socket_options=None
DEBUG:httpcore.connection:connect_tcp.complete return_value=<httpcore._backends.sync.SyncStream object at 0x7fda81e29a30>
DEBUG:httpcore.connection:start_tls.started ssl_context=<ssl.SSLContext object at 0x7fda81e0c150> server_hostname='opensky-network.org' timeout=5.0
DEBUG:httpcore.connection:start_tls.complete return_value=<httpcore._backends.sync.SyncStream object at 0x7fda81e29370>
DEBUG:httpcore.http11:send_request_headers.started request=<Request [b'GET']>
DEBUG:httpcore.http11:send_request_headers.complete
DEBUG:httpcore.http11:send_request_body.started request=<Request [b'GET']>
DEBUG:httpcore.http11:send_request_body.complete
DEBUG:httpcore.http11:receive_response_headers.started request=<Request [b'GET']>
DEBUG:httpcore.http11:receive_response_headers.complete return_value=(b'HTTP/1.1', 403, b'', [(b'Server', b'nginx/1.17.6'), (b'Date', b'Mon, 19 Aug 2024 09:01:34 GMT'), (b'Transfer-Encoding', b'chunked'), (b'Connection', b'keep-alive'), (b'X-Content-Type-Options', b'nosniff'), (b'X-XSS-Protection', b'1; mode=block'), (b'Cache-Control', b'no-cache, no-store, max-age=0, must-revalidate'), (b'Pragma', b'no-cache'), (b'Expires', b'0'), (b'X-Frame-Options', b'DENY')])
INFO:httpx:HTTP Request: GET https://opensky-network.org/api/states/all "HTTP/1.1 403 "
DEBUG:httpcore.http11:receive_response_body.started request=<Request [b'GET']>
DEBUG:httpcore.http11:receive_response_body.complete
DEBUG:httpcore.http11:response_closed.started
DEBUG:httpcore.http11:response_closed.complete

Please follow these steps to make it more efficient to solve your issue:

  • [x] Search for duplicate issues.
  • [x] Use the latest version of traffic, ideally the HEAD of the github, and activate the DEBUG logging level.
  • [x] Describe how to reproduce the bug and include the full code and data to reproduce it, ideally using a sample trajectory from the library. Sample trajectories are extensively used in the tests suite.
  • [x] Limit the output of your exceptions to what is strictly necessary.

You may activate the DEBUG level with the following snippet:

import logging
logging.basicConfig(level=logging.DEBUG)

simonrp84 avatar Aug 19 '24 09:08 simonrp84

For what it's worth, I am aware of: #413, which is also mine, but this appears to be a different issue. In that case I couldn't retrieve the states via curl and so it was an opensky issue. Here I can successfully retrieve the states outside of traffic so it's a library problem I think. Hence opening a new issue - apologies if you would have preferred I re-opn the old issue!

simonrp84 avatar Aug 19 '24 09:08 simonrp84

Hi Simon, that is weird as I cannot reproduce on my side. Are you using the latest version of pyopensky? If yes, can you check with the HEAD of the repository?

xoolive avatar Aug 19 '24 16:08 xoolive

Hi @simonrp84 I published this morning a new version of pyopensky (wrapped by traffic) to better handle this kind of errors, can you try again? If it fails, please reopen another issue in pyopensky.

xoolive avatar Sep 04 '24 12:09 xoolive

Sorry for not getting back to you on this - busy few weeks! Will try with pyopensky as requested in the next days.

simonrp84 avatar Sep 04 '24 17:09 simonrp84

FWIW there's a block list that gets ever longer due to a lot of abuse. From the debug I don't fully understand, is it a 401 or 403 now? If you check again, let me know and I can look into the server logs.

masorx avatar Oct 25 '24 21:10 masorx