Live: make maximum WebSocket message size configurable (#99770)
Co-authored-by: Chris Marchbanks <chris.marchbanks@grafana.com>
This commit is contained in:
co-authored by
Chris Marchbanks
parent
9d5af95565
commit
408e3e91a8
@@ -269,12 +269,14 @@ func ProvideService(plugCtxProvider *plugincontext.Provider, cfg *setting.Cfg, r
|
||||
originGlobs, _ := setting.GetAllowedOriginGlobs(originPatterns) // error already checked on config load.
|
||||
checkOrigin := getCheckOriginFunc(appURL, originPatterns, originGlobs)
|
||||
|
||||
wsCfg := centrifuge.WebsocketConfig{
|
||||
ReadBufferSize: 1024,
|
||||
WriteBufferSize: 1024,
|
||||
CheckOrigin: checkOrigin,
|
||||
MessageSizeLimit: cfg.LiveMessageSizeLimit,
|
||||
}
|
||||
// Use a pure websocket transport.
|
||||
wsHandler := centrifuge.NewWebsocketHandler(node, centrifuge.WebsocketConfig{
|
||||
ReadBufferSize: 1024,
|
||||
WriteBufferSize: 1024,
|
||||
CheckOrigin: checkOrigin,
|
||||
})
|
||||
wsHandler := centrifuge.NewWebsocketHandler(node, wsCfg)
|
||||
|
||||
pushWSHandler := pushws.NewHandler(g.ManagedStreamRunner, pushws.Config{
|
||||
ReadBufferSize: 1024,
|
||||
|
||||
@@ -435,6 +435,9 @@ type Cfg struct {
|
||||
// LiveAllowedOrigins is a set of origins accepted by Live. If not provided
|
||||
// then Live uses AppURL as the only allowed origin.
|
||||
LiveAllowedOrigins []string
|
||||
// LiveMessageSizeLimit is the maximum size in bytes of Websocket messages
|
||||
// from clients. Defaults to 64KB.
|
||||
LiveMessageSizeLimit int
|
||||
|
||||
// Grafana.com URL, used for OAuth redirect.
|
||||
GrafanaComURL string
|
||||
@@ -1974,6 +1977,10 @@ func (cfg *Cfg) readLiveSettings(iniFile *ini.File) error {
|
||||
if cfg.LiveMaxConnections < -1 {
|
||||
return fmt.Errorf("unexpected value %d for [live] max_connections", cfg.LiveMaxConnections)
|
||||
}
|
||||
cfg.LiveMessageSizeLimit = section.Key("message_size_limit").MustInt(65536)
|
||||
if cfg.LiveMessageSizeLimit < -1 {
|
||||
return fmt.Errorf("unexpected value %d for [live] message_size_limit", cfg.LiveMaxConnections)
|
||||
}
|
||||
cfg.LiveHAEngine = section.Key("ha_engine").MustString("")
|
||||
switch cfg.LiveHAEngine {
|
||||
case "", "redis":
|
||||
|
||||
Reference in New Issue
Block a user