Connecting Through a SOCKS5 Proxy¶
If your target service is only reachable via an SSH gateway or resides behind a
firewall, you can route your pydase.Client connection through a local
SOCKS5 proxy. This is particularly useful in network environments where direct access to
the service is not possible.
Setting Up a SOCKS5 Proxy¶
You can create a local SOCKS5 proxy using SSH’s
-D option:
This command sets up a SOCKS5 proxy on localhost:2222, securely forwarding traffic
over the SSH connection.
Using the Proxy in Your Python Client¶
Once the proxy is running, configure the pydase.Client to route
traffic through it using the proxy_url parameter:
import pydase
client = pydase.Client(
url="ws://target-service:8001",
proxy_url="socks5://localhost:2222"
).proxy
- You can also use this setup with
wss://URLs for encrypted WebSocket connections.
Installing Required Dependencies¶
To use this feature, you must install the optional socks dependency group, which
includes aiohttp_socks:
poetrypip