fix(portal): Decrease WS timeouts for relays and gateways (#6112)

Related to #6095
This commit is contained in:
Andrew Dryga
2024-07-31 16:34:52 -06:00
committed by GitHub
parent 78cca053a6
commit 8e1eb2429d
2 changed files with 14 additions and 11 deletions

View File

@@ -24,9 +24,9 @@ defmodule API.Endpoint do
# https://hexdocs.pm/phoenix/Phoenix.Logger.html
plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint]
socket "/gateway", API.Gateway.Socket, API.Sockets.options()
socket "/client", API.Client.Socket, API.Sockets.options()
socket "/relay", API.Relay.Socket, API.Sockets.options()
socket "/gateway", API.Gateway.Socket, API.Sockets.options(timeout: :timer.seconds(37))
socket "/client", API.Client.Socket, API.Sockets.options(timeout: :timer.seconds(307))
socket "/relay", API.Relay.Socket, API.Sockets.options(timeout: :timer.seconds(41))
plug :fetch_user_agent
plug API.Router

View File

@@ -5,15 +5,18 @@ defmodule API.Sockets do
"""
require Logger
def options do
def options(websocket_overrides \\ []) do
[
websocket: [
timeout: :timer.seconds(307),
transport_log: :debug,
check_origin: :conn,
connect_info: [:trace_context_headers, :user_agent, :peer_data, :x_headers],
error_handler: {__MODULE__, :handle_error, []}
],
websocket:
Keyword.merge(
[
transport_log: :debug,
check_origin: :conn,
connect_info: [:trace_context_headers, :user_agent, :peer_data, :x_headers],
error_handler: {__MODULE__, :handle_error, []}
],
websocket_overrides
),
longpoll: false
]
end