wulfey
wulfey•14mo ago

Connect to a WebSocket through a HTTP(S)/SOCKS5 proxy

Title - I am trying to connect to a wss:// websocket through a proxy of choice at runtime. Is there a way to do this alike to Deno.createHttpClient for regular requests? If not (and I would say it is in fact more complicated), what should I do to achieve this?
1 Reply
Deno AI Helper
Deno AI Helper•14mo ago
Based on the documentation, there isn't a direct way to connect to a WebSocket through a HTTP(S)/SOCKS5 proxy using Deno's WebSocket API. The WebSocket API provided by Deno allows you to create and manage a WebSocket connection to a server, as well as send and receive data on the connection. However, it does not provide a built-in way to connect through a proxy. The Deno.createHttpClient function you mentioned is used to create an HTTP client with custom settings, but it doesn't apply to WebSocket connections. To achieve this, you might need to use a third-party library that supports WebSocket connections through a proxy, or implement the proxy handling logic yourself. Please note that this advice is not from the documentation, and you should consider it as a general direction rather than a specific solution. If you decide to implement it yourself, you would need to manually handle the HTTP CONNECT method to establish a network tunnel to the WebSocket server through the proxy. This can be quite complex and requires a good understanding of both the HTTP and WebSocket protocols. Remember to always check the documentation for the most up-to-date and accurate information. 🦕