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: support uws idle timeout #418

Merged
merged 4 commits into from
Oct 4, 2023
Merged
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 etc/http-server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export type ITestHttpServerComponent<Context extends object> = IHttpServerCompon
// @public (undocumented)
export type IUwsHttpServerOptions = {
compression: boolean;
idleTimeout?: number;
};

// @alpha (undocumented)
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ export type IHttpServerOptions = {
*/
export type IUwsHttpServerOptions = {
compression: boolean
idleTimeout?: number
}
4 changes: 2 additions & 2 deletions src/uws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ export async function createUwsHttpServer<Context extends object>(
const host = await config.requireString("HTTP_SERVER_HOST")

const server: uwslib.TemplatedApp = uwslib
.App({
})
.App({})
.ws("/*", {
compression: options.compression ? uwslib.SHARED_COMPRESSOR : uwslib.DISABLED,
upgrade: wsHandler,
idleTimeout: options.idleTimeout ?? 120,
open(_ws) {
const ws = _ws as WsUserData
ws.websocketConnect(ws as any)
Expand Down