Make WebSocketSendTimeout configurable

polling-api
Noah 2023-09-30 12:46:45 -07:00
parent a1b0d2e965
commit 15b291826e
3 changed files with 11 additions and 9 deletions

View File

@ -13,7 +13,7 @@ import (
// Version of the config format - when new fields are added, it will attempt // Version of the config format - when new fields are added, it will attempt
// to write the settings.toml to disk so new defaults populate. // to write the settings.toml to disk so new defaults populate.
var currentVersion = 8 var currentVersion = 9
// Config for your BareRTC app. // Config for your BareRTC app.
type Config struct { type Config struct {
@ -36,9 +36,10 @@ type Config struct {
UseXForwardedFor bool UseXForwardedFor bool
WebSocketReadLimit int64 WebSocketReadLimit int64
MaxImageWidth int WebSocketSendTimeout int
PreviewImageWidth int MaxImageWidth int
PreviewImageWidth int
TURN TurnConfig TURN TurnConfig
@ -112,9 +113,10 @@ func DefaultConfig() Config {
CORSHosts: []string{ CORSHosts: []string{
"https://www.example.com", "https://www.example.com",
}, },
WebSocketReadLimit: 1024 * 1024 * 40, // 40 MB. WebSocketReadLimit: 1024 * 1024 * 40, // 40 MB.
MaxImageWidth: 1280, WebSocketSendTimeout: 10, // seconds
PreviewImageWidth: 360, MaxImageWidth: 1280,
PreviewImageWidth: 360,
PublicChannels: []Channel{ PublicChannels: []Channel{
{ {
ID: "lobby", ID: "lobby",

View File

@ -218,7 +218,7 @@ func (s *Server) WebSocket() http.HandlerFunc {
for { for {
select { select {
case msg := <-sub.messages: case msg := <-sub.messages:
err = writeTimeout(ctx, time.Second*15, c, msg) err = writeTimeout(ctx, time.Second*time.Duration(config.Current.WebSocketSendTimeout), c, msg)
if err != nil { if err != nil {
return return
} }

View File

@ -57,7 +57,7 @@ export default {
windowFocusedAt: new Date(), windowFocusedAt: new Date(),
// Disconnect spamming: don't retry too many times. // Disconnect spamming: don't retry too many times.
disconnectLimit: 3, disconnectLimit: 2,
disconnectCount: 0, disconnectCount: 0,
// Temp: spam counting for OF links // Temp: spam counting for OF links