Ensure WriteTimeout > TimeoutBroadcastTxCommit (#3443)

* Make sure config.TimeoutBroadcastTxCommit < rpcserver.WriteTimeout()

* remove redundant comment

* libs/rpc/http_server: move Read/WriteTimeout into Config

* increase defaults for read/write timeouts

Based on this article
https://www.digitalocean.com/community/tutorials/how-to-optimize-nginx-configuration

* WriteTimeout should be larger than TimeoutBroadcastTxCommit

* set a deadline for subscribing to txs

* extract duration into const

* add two changelog entries

* Update CHANGELOG_PENDING.md

Co-Authored-By: melekes <anton.kalyaev@gmail.com>

* Update CHANGELOG_PENDING.md

Co-Authored-By: melekes <anton.kalyaev@gmail.com>

* 12 -> 10

* changelog

* changelog
This commit is contained in:
Ismail Khoffi
2019-03-20 00:45:51 +01:00
committed by Ethan Buchman
parent 5f68fbae37
commit 1e3469789d
16 changed files with 123 additions and 46 deletions

View File

@ -1,6 +1,7 @@
package rpctypes
import (
"context"
"encoding/json"
"fmt"
"net/http"
@ -243,6 +244,8 @@ type WSRPCConnection interface {
TryWriteRPCResponse(resp RPCResponse) bool
// Codec returns an Amino codec used.
Codec() *amino.Codec
// Context returns the connection's context.
Context() context.Context
}
// Context is the first parameter for all functions. It carries a json-rpc
@ -260,8 +263,12 @@ type Context struct {
HTTPReq *http.Request
}
// RemoteAddr returns either HTTPReq#RemoteAddr or result of the
// WSConn#GetRemoteAddr().
// RemoteAddr returns the remote address (usually a string "IP:port").
// If neither HTTPReq nor WSConn is set, an empty string is returned.
// HTTP:
// http.Request#RemoteAddr
// WS:
// result of GetRemoteAddr
func (ctx *Context) RemoteAddr() string {
if ctx.HTTPReq != nil {
return ctx.HTTPReq.RemoteAddr
@ -271,6 +278,22 @@ func (ctx *Context) RemoteAddr() string {
return ""
}
// Context returns the request's context.
// The returned context is always non-nil; it defaults to the background context.
// HTTP:
// The context is canceled when the client's connection closes, the request
// is canceled (with HTTP/2), or when the ServeHTTP method returns.
// WS:
// The context is canceled when the client's connections closes.
func (ctx *Context) Context() context.Context {
if ctx.HTTPReq != nil {
return ctx.HTTPReq.Context()
} else if ctx.WSConn != nil {
return ctx.WSConn.Context()
}
return context.Background()
}
//----------------------------------------
// SOCKETS