Spaces:
Runtime error
Runtime error
Lewis Kimaru
feat: add WebSocket and HTTP tunnels for ISUP protocol to bypass HF port limitations
5003a03 Download test/test_connection_simple.py from Atomio/hikvision-isup: direct link, hf CLI and curl.
- Browser
- Download file 2.51 kB
-
https://huggingface.co/spaces/Atomio/hikvision-isup/resolve/main/test/test_connection_simple.py
- Command line
-
hf download hf://spaces/Atomio/hikvision-isup/test/test_connection_simple.py
-
curl -L -o test_connection_simple.py https://huggingface.co/spaces/Atomio/hikvision-isup/resolve/main/test/test_connection_simple.py
2.51 kB
| #!/usr/bin/env python3 | |
| """ | |
| Simple connection test to diagnose connectivity issues | |
| """ | |
| import socket | |
| import sys | |
| def test_connection(): | |
| """Test basic TCP connection""" | |
| host = 'localhost' | |
| port = 7660 | |
| print(f"Testing connection to {host}:{port}...") | |
| try: | |
| # Create socket with timeout | |
| sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| sock.settimeout(10.0) # 10 second timeout | |
| print("Attempting to connect...") | |
| result = sock.connect_ex((host, port)) | |
| if result == 0: | |
| print("β Connection successful!") | |
| sock.close() | |
| return True | |
| else: | |
| print(f"β Connection failed with error code: {result}") | |
| return False | |
| except socket.gaierror as e: | |
| print(f"β DNS resolution failed: {e}") | |
| return False | |
| except socket.timeout: | |
| print("β Connection timed out") | |
| return False | |
| except Exception as e: | |
| print(f"β Connection failed: {e}") | |
| return False | |
| finally: | |
| try: | |
| sock.close() | |
| except: | |
| pass | |
| def test_http_connection(): | |
| """Test if the web interface is accessible""" | |
| import urllib.request | |
| import urllib.error | |
| url = 'https://atomio-hikvision-isup.hf.space' | |
| print(f"\nTesting HTTP connection to {url}...") | |
| try: | |
| with urllib.request.urlopen(url, timeout=10) as response: | |
| print(f"β HTTP connection successful! Status: {response.status}") | |
| return True | |
| except urllib.error.URLError as e: | |
| print(f"β HTTP connection failed: {e}") | |
| return False | |
| except Exception as e: | |
| print(f"β HTTP connection error: {e}") | |
| return False | |
| if __name__ == "__main__": | |
| print("π Diagnosing connection to Hugging Face Space...") | |
| print("=" * 50) | |
| # Test HTTP first | |
| http_ok = test_http_connection() | |
| # Test TCP connection | |
| tcp_ok = test_connection() | |
| print("\n" + "=" * 50) | |
| print("π Results:") | |
| print(f"HTTP accessible: {'β ' if http_ok else 'β'}") | |
| print(f"TCP port 7660 accessible: {'β ' if tcp_ok else 'β'}") | |
| if http_ok and not tcp_ok: | |
| print("\nπ‘ The web interface is accessible but TCP port 7660 is not.") | |
| print(" This suggests the Hugging Face Space might not expose TCP ports externally.") | |
| print(" You may need to test the connection from within the Space itself.") |