mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 19:13:07 +08:00
Live: make maximum WebSocket message size configurable (#99770)
Co-authored-by: Chris Marchbanks <chris.marchbanks@grafana.com>
This commit is contained in:
@ -1803,6 +1803,10 @@ preinstall_disabled = false
|
||||
# tuning. 0 disables Live, -1 means unlimited connections.
|
||||
max_connections = 100
|
||||
|
||||
# message_size_limit is the maximum size in bytes of Websocket messages from clients. Defaults to 64KB.
|
||||
# The limit can be disabled by setting it to -1.
|
||||
message_size_limit = 65536
|
||||
|
||||
# allowed_origins is a comma-separated list of origins that can establish connection with Grafana Live.
|
||||
# If not set then origin will be matched over root_url. Supports wildcard symbol "*".
|
||||
allowed_origins =
|
||||
|
@ -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