mirror of
https://github.com/Retropex/custom-ocean.xyz-dashboard.git
synced 2025-05-12 19:20:45 +02:00
Improve API connectivity checks in MiningDashboardService
Updated the `_test_api_connectivity` method in `data_service.py` to include additional headers and enhanced logging. The method now attempts to ping a wallet-specific endpoint first, followed by a standard ping and a statsnap endpoint if necessary. Detailed error messages and a debug URL have been added for better troubleshooting, improving the overall robustness and clarity of the connectivity checks.
This commit is contained in:
parent
f52b947633
commit
c9a2f927ff
@ -46,8 +46,49 @@ class MiningDashboardService:
|
||||
def _test_api_connectivity(self):
|
||||
"""Test if the new Ocean.xyz Beta API is available."""
|
||||
try:
|
||||
response = self.session.get(f"{self.ocean_api_base}/ping", timeout=5)
|
||||
return response.ok and response.text.strip() == "PONG"
|
||||
# Add helpful headers
|
||||
headers = {
|
||||
'User-Agent': 'Mozilla/5.0 Mining Dashboard',
|
||||
'Accept': 'application/json',
|
||||
'Cache-Control': 'no-cache'
|
||||
}
|
||||
|
||||
# Try wallet-specific ping endpoint first since you confirmed it works
|
||||
wallet_ping_url = f"{self.ocean_api_base}/ping/{self.wallet}"
|
||||
logging.info(f"Testing Ocean API connectivity with wallet-specific ping: {wallet_ping_url}")
|
||||
|
||||
response = self.session.get(wallet_ping_url, headers=headers, timeout=5)
|
||||
if response.ok:
|
||||
logging.info("Ocean.xyz Beta API is available with wallet-specific ping endpoint")
|
||||
return True
|
||||
|
||||
# If wallet-specific ping fails, try standard ping
|
||||
standard_ping_url = f"{self.ocean_api_base}/ping"
|
||||
logging.info(f"Testing Ocean API with standard ping: {standard_ping_url}")
|
||||
|
||||
response = self.session.get(standard_ping_url, headers=headers, timeout=5)
|
||||
if response.ok and response.text.strip() == "PONG":
|
||||
logging.info("Ocean.xyz Beta API is available with standard ping endpoint")
|
||||
return True
|
||||
|
||||
# If both pings fail, try a wallet-specific endpoint that should return data
|
||||
statsnap_url = f"{self.ocean_api_base}/statsnap/{self.wallet}"
|
||||
logging.info(f"Testing Ocean API with statsnap endpoint: {statsnap_url}")
|
||||
|
||||
response = self.session.get(statsnap_url, headers=headers, timeout=5)
|
||||
if response.ok:
|
||||
logging.info("Ocean.xyz Beta API is available with statsnap endpoint")
|
||||
return True
|
||||
|
||||
# All attempts failed
|
||||
logging.error("All Ocean.xyz Beta API connectivity tests failed")
|
||||
|
||||
# Log the exact URL that you confirmed works for debugging
|
||||
debug_url = f"https://api.ocean.xyz/v1/ping/{self.wallet}"
|
||||
logging.info(f"Note: The URL {debug_url} should work according to user confirmation")
|
||||
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"Error testing Ocean.xyz Beta API connectivity: {e}")
|
||||
return False
|
||||
|
Loading…
Reference in New Issue
Block a user