Set idleTimeout to 30s for WebSocket connections

This commit is contained in:
Alex Gleason 2024-05-25 13:39:19 -05:00
parent 6bfe611847
commit 16558e24c9
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 2 additions and 2 deletions

View File

@ -49,7 +49,7 @@ const streamingController: AppController = (c) => {
return c.json({ error: 'Invalid access token' }, 401); return c.json({ error: 'Invalid access token' }, 401);
} }
const { socket, response } = Deno.upgradeWebSocket(c.req.raw, { protocol: token }); const { socket, response } = Deno.upgradeWebSocket(c.req.raw, { protocol: token, idleTimeout: 30 });
function send(name: string, payload: object) { function send(name: string, payload: object) {
if (socket.readyState === WebSocket.OPEN) { if (socket.readyState === WebSocket.OPEN) {

View File

@ -154,7 +154,7 @@ const relayController: AppController = (c, next) => {
return c.text('Please use a Nostr client to connect.', 400); return c.text('Please use a Nostr client to connect.', 400);
} }
const { socket, response } = Deno.upgradeWebSocket(c.req.raw); const { socket, response } = Deno.upgradeWebSocket(c.req.raw, { idleTimeout: 30 });
connectStream(socket); connectStream(socket);
return response; return response;