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

feat(websocket): use proxy for websocket connections #10149

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class WebSocketManager extends EventEmitter {
}
if (!this._ws) {
const wsOptions = {
agent: ws.agent,
intents: intents.bitfield,
rest: this.client.rest,
token: this.client.token,
Expand Down
5 changes: 5 additions & 0 deletions packages/ws/src/ws/WebSocketManager.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Agent } from 'node:http';
import type { REST } from '@discordjs/rest';
import { range, type Awaitable } from '@discordjs/util';
import { polyfillDispose } from '@discordjs/util';
Expand Down Expand Up @@ -77,6 +78,10 @@ export interface RequiredWebSocketManagerOptions {
* Optional additional configuration for the WebSocketManager
*/
export interface OptionalWebSocketManagerOptions {
/**
* The proxy agent to use for the WebSocket connections
*/
agent?: Agent;
/**
* Builds an identify throttler to use for this manager's shards
*/
Expand Down
1 change: 1 addition & 0 deletions packages/ws/src/ws/WebSocketShard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ export class WebSocketShard extends AsyncEventEmitter<WebSocketShardEventsMap> {

const connection = new WebSocketConstructor(url, {
handshakeTimeout: this.strategy.options.handshakeTimeout ?? undefined,
agent: this.strategy.options.agent,
});

connection.binaryType = 'arraybuffer';
Expand Down
Loading