Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set proxy? #124

Open
Liang-YY opened this issue Jan 4, 2023 · 1 comment
Open

How to set proxy? #124

Liang-YY opened this issue Jan 4, 2023 · 1 comment

Comments

@Liang-YY
Copy link

Liang-YY commented Jan 4, 2023

How to set proxy?

@reme3d2y
Copy link

reme3d2y commented Nov 3, 2023

Maybe someone will find it useful

const HttpsProxyAgent = require("https-proxy-agent");
const WebSocket = require("ws");
const ReconnectingWebSocket = require("reconnecting-websocket");

const wsUrl = "wss://some.url";

const agent = new HttpsProxyAgent("http://ip:port");

class WebSocketWithAgent extends WebSocket {
    constructor(url, protocols) {
        super(url, protocols, {
            agent,
        });
    }
}

const ws = new ReconnectingWebSocket(wsUrl, [], { WebSocket: WebSocketWithAgent });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants