-
Notifications
You must be signed in to change notification settings - Fork 454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option for websocket message size limit #2266
Changes from 2 commits
6a1f54d
9dda8ef
dc706bf
3b0ea4a
a303472
da8144f
725ec52
69a3e9f
a1f43a3
8874a66
7f7177b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,14 +21,15 @@ import ( | |
) | ||
|
||
type ClientConfig struct { | ||
URL string `json:"url,omitempty" koanf:"url"` | ||
JWTSecret string `json:"jwtsecret,omitempty" koanf:"jwtsecret"` | ||
Timeout time.Duration `json:"timeout,omitempty" koanf:"timeout" reload:"hot"` | ||
Retries uint `json:"retries,omitempty" koanf:"retries" reload:"hot"` | ||
ConnectionWait time.Duration `json:"connection-wait,omitempty" koanf:"connection-wait"` | ||
ArgLogLimit uint `json:"arg-log-limit,omitempty" koanf:"arg-log-limit" reload:"hot"` | ||
RetryErrors string `json:"retry-errors,omitempty" koanf:"retry-errors" reload:"hot"` | ||
RetryDelay time.Duration `json:"retry-delay,omitempty" koanf:"retry-delay"` | ||
URL string `json:"url,omitempty" koanf:"url"` | ||
JWTSecret string `json:"jwtsecret,omitempty" koanf:"jwtsecret"` | ||
Timeout time.Duration `json:"timeout,omitempty" koanf:"timeout" reload:"hot"` | ||
Retries uint `json:"retries,omitempty" koanf:"retries" reload:"hot"` | ||
ConnectionWait time.Duration `json:"connection-wait,omitempty" koanf:"connection-wait"` | ||
ArgLogLimit uint `json:"arg-log-limit,omitempty" koanf:"arg-log-limit" reload:"hot"` | ||
RetryErrors string `json:"retry-errors,omitempty" koanf:"retry-errors" reload:"hot"` | ||
RetryDelay time.Duration `json:"retry-delay,omitempty" koanf:"retry-delay"` | ||
WebsocketMessageSizeLimit int64 `json:"websocket-message-size-limit,omitempty" koanf:"websocket-message-size-limit"` | ||
|
||
retryErrors *regexp.Regexp | ||
} | ||
|
@@ -46,8 +47,9 @@ func (c *ClientConfig) Validate() error { | |
type ClientConfigFetcher func() *ClientConfig | ||
|
||
var TestClientConfig = ClientConfig{ | ||
URL: "self", | ||
JWTSecret: "", | ||
URL: "self", | ||
JWTSecret: "", | ||
WebsocketMessageSizeLimit: 32 * 1024 * 1024, | ||
} | ||
|
||
var DefaultClientConfig = ClientConfig{ | ||
|
@@ -56,6 +58,8 @@ var DefaultClientConfig = ClientConfig{ | |
Retries: 3, | ||
RetryErrors: "websocket: close.*|dial tcp .*|.*i/o timeout|.*connection reset by peer|.*connection refused", | ||
ArgLogLimit: 2048, | ||
// Use geth's unexported wsDefaultReadLimit from rpc/websocket.go | ||
WebsocketMessageSizeLimit: 32 * 1024 * 1024, | ||
} | ||
|
||
func RPCClientAddOptions(prefix string, f *flag.FlagSet, defaultConfig *ClientConfig) { | ||
|
@@ -67,6 +71,7 @@ func RPCClientAddOptions(prefix string, f *flag.FlagSet, defaultConfig *ClientCo | |
f.Uint(prefix+".retries", defaultConfig.Retries, "number of retries in case of failure(0 mean one attempt)") | ||
f.String(prefix+".retry-errors", defaultConfig.RetryErrors, "Errors matching this regular expression are automatically retried") | ||
f.Duration(prefix+".retry-delay", defaultConfig.RetryDelay, "delay between retries") | ||
f.Int64(prefix+".websocket-message-size-limit", defaultConfig.WebsocketMessageSizeLimit, "websocket message size limit used by the RPC client. 0 means no limit") | ||
} | ||
|
||
type RpcClient struct { | ||
|
@@ -256,9 +261,9 @@ func (c *RpcClient) Start(ctx_in context.Context) error { | |
var err error | ||
var client *rpc.Client | ||
if jwt == nil { | ||
client, err = rpc.DialContext(ctx, url) | ||
client, err = rpc.DialOptions(ctx, url, rpc.WithWebsocketMessageSizeLimit(c.config().WebsocketMessageSizeLimit)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's test here if WebsocketMessageSizeLimit == 0 (it can happen e.g. for validation-server-configs). If it's 0 either use default or don't apply rpc.WithWebsocketMessageSizeLimit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} else { | ||
client, err = rpc.DialOptions(ctx, url, rpc.WithHTTPAuth(node.NewJWTAuth([32]byte(*jwt)))) | ||
client, err = rpc.DialOptions(ctx, url, rpc.WithHTTPAuth(node.NewJWTAuth([32]byte(*jwt))), rpc.WithWebsocketMessageSizeLimit(c.config().WebsocketMessageSizeLimit)) | ||
} | ||
cancelCtx() | ||
if err == nil { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's increase this to 256 MiB (for the other websocket clients as well). All of these websocket clients are expecting the server to be honest.