rpc: increase server-side WS read limit for websocket RPC message
Close #2505. Turns out that existing limit is too low to fit `submitp2pnotaryrequest`. Thanks to @alexvanin for discovering this.
This commit is contained in:
parent
7bda933e32
commit
1a07d0f039
1 changed files with 6 additions and 6 deletions
|
@ -59,8 +59,10 @@ type (
|
||||||
// Server represents the JSON-RPC 2.0 server.
|
// Server represents the JSON-RPC 2.0 server.
|
||||||
Server struct {
|
Server struct {
|
||||||
*http.Server
|
*http.Server
|
||||||
chain blockchainer.Blockchainer
|
chain blockchainer.Blockchainer
|
||||||
config rpc.Config
|
config rpc.Config
|
||||||
|
// wsReadLimit represents web-socket message limit for a receiving side.
|
||||||
|
wsReadLimit int64
|
||||||
network netmode.Magic
|
network netmode.Magic
|
||||||
stateRootEnabled bool
|
stateRootEnabled bool
|
||||||
coreServer *network.Server
|
coreServer *network.Server
|
||||||
|
@ -87,9 +89,6 @@ type (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Message limit for a receiving side.
|
|
||||||
wsReadLimit = 4096
|
|
||||||
|
|
||||||
// Disconnection timeout.
|
// Disconnection timeout.
|
||||||
wsPongLimit = 60 * time.Second
|
wsPongLimit = 60 * time.Second
|
||||||
|
|
||||||
|
@ -188,6 +187,7 @@ func New(chain blockchainer.Blockchainer, conf rpc.Config, coreServer *network.S
|
||||||
Server: httpServer,
|
Server: httpServer,
|
||||||
chain: chain,
|
chain: chain,
|
||||||
config: conf,
|
config: conf,
|
||||||
|
wsReadLimit: int64(chain.GetConfig().MaxBlockSize*4)/3 + 1024, // Enough for Base64-encoded content of `submitblock` and `submitp2pnotaryrequest`.
|
||||||
network: chain.GetConfig().Magic,
|
network: chain.GetConfig().Magic,
|
||||||
stateRootEnabled: chain.GetConfig().StateRootInHeader,
|
stateRootEnabled: chain.GetConfig().StateRootInHeader,
|
||||||
coreServer: coreServer,
|
coreServer: coreServer,
|
||||||
|
@ -437,7 +437,7 @@ drainloop:
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) handleWsReads(ws *websocket.Conn, resChan chan<- response.AbstractResult, subscr *subscriber) {
|
func (s *Server) handleWsReads(ws *websocket.Conn, resChan chan<- response.AbstractResult, subscr *subscriber) {
|
||||||
ws.SetReadLimit(wsReadLimit)
|
ws.SetReadLimit(s.wsReadLimit)
|
||||||
err := ws.SetReadDeadline(time.Now().Add(wsPongLimit))
|
err := ws.SetReadDeadline(time.Now().Add(wsPongLimit))
|
||||||
ws.SetPongHandler(func(string) error { return ws.SetReadDeadline(time.Now().Add(wsPongLimit)) })
|
ws.SetPongHandler(func(string) error { return ws.SetReadDeadline(time.Now().Add(wsPongLimit)) })
|
||||||
requestloop:
|
requestloop:
|
||||||
|
|
Loading…
Add table
Reference in a new issue