diff --git a/server/hdl_websock.go b/server/hdl_websock.go index 51621eeb..347b4254 100644 --- a/server/hdl_websock.go +++ b/server/hdl_websock.go @@ -159,7 +159,7 @@ func wsWrite(ws *websocket.Conn, mt int, msg any) error { var upgrader = websocket.Upgrader{ ReadBufferSize: 1024, WriteBufferSize: 1024, - EnableCompression: true, + EnableCompression: globals.wsCompression, // Allow connections from any Origin CheckOrigin: func(r *http.Request) bool { return true }, } diff --git a/server/main.go b/server/main.go index e891ee07..da59a91a 100644 --- a/server/main.go +++ b/server/main.go @@ -195,6 +195,9 @@ var globals struct { // ICE servers config (video calling) iceServers []iceServer + + // Websocket per-message compression negotiation is enabled. + wsCompression bool } // Credential validator config. @@ -245,6 +248,9 @@ type configType struct { ApiPath string `json:"api_path"` // Cache-Control value for static content. CacheControl int `json:"cache_control"` + // If true, do not attempt to negotiate websocket per message compression (RFC 7692.4). + // It should be disabled (set to true) if you are using MSFT IIS as reverse proxy. + WSCompressionDisabled bool `json:"ws_compression_disabled"` // Address:port to listen for gRPC clients. If blank gRPC support will not be initialized. // Could be overridden from the command line with --grpc_listen. GrpcListen string `json:"grpc_listen"` @@ -545,6 +551,9 @@ func main() { globals.defaultCountryCode = defaultCountryCode } + // Websocket compression. + globals.wsCompression = !config.WSCompressionDisabled + if config.Media != nil { if config.Media.UseHandler == "" { config.Media = nil diff --git a/server/tinode.conf b/server/tinode.conf index 459a52d8..b3d59dea 100644 --- a/server/tinode.conf +++ b/server/tinode.conf @@ -15,6 +15,10 @@ // Cache-Control header for static content in seconds. 39600 is 11 hours. "cache_control": 39600, + // If true, do not attempt to negotiate websocket per message compression (RFC 7692.4). + // It should be disabled (set to true) if you are using MSFT IIS as a reverse proxy. + "ws_compression_disabled": false, + // URL path for mounting the directory with static files. "static_mount": "/",