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

Add custom idleTimeout env variable #1089

Open
wants to merge 1 commit into
base: 1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export class Cli {
METRICS_SERVER_PORT: 'metrics.port',
MODE: 'mode',
PORT: 'port',
IDLE_TIMEOUT: 'idleTimeout',
PATH_PREFIX: 'pathPrefix',
PRESENCE_MAX_MEMBER_SIZE: 'presence.maxMemberSizeInKb',
PRESENCE_MAX_MEMBERS: 'presence.maxMembersPerChannel',
Expand Down
1 change: 1 addition & 0 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export interface Options {
};
mode: string;
port: number;
idleTimeout: number;
pathPrefix: string;
presence: {
maxMembersPerChannel: string|number;
Expand Down
3 changes: 2 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ export class Server {
},
mode: 'full',
port: 6001,
idleTimeout : 120, // According to protocol
pathPrefix: '',
presence: {
maxMembersPerChannel: 100,
Expand Down Expand Up @@ -632,7 +633,7 @@ export class Server {
return new Promise(resolve => {
if (this.canProcessRequests()) {
server = server.ws(this.url('/app/:id'), {
idleTimeout: 120, // According to protocol
idleTimeout: this.options.idleTimeout,
maxBackpressure: 1024 * 1024,
maxPayloadLength: 100 * 1024 * 1024, // 100 MB
message: (ws: WebSocket, message: uWebSocketMessage, isBinary: boolean) => this.wsHandler.onMessage(ws, message, isBinary),
Expand Down
2 changes: 1 addition & 1 deletion src/ws-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ export class WsHandler {
} catch (e) {
//
}
}, 120_000);
}, this.server.options.idleTimeout * 1000);
}

/**
Expand Down