Skip to content
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

fix(rpc): set const ReadHeaderTimeout to dymint RPC server #671

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions rpc/json/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,21 @@ type unsubscribeArgs struct {
type unsubscribeAllArgs struct{}

// info API
type healthArgs struct{}
type statusArgs struct{}
type netInfoArgs struct{}
type blockchainInfoArgs struct {
MinHeight StrInt64 `json:"minHeight"`
MaxHeight StrInt64 `json:"maxHeight"`
}
type genesisArgs struct{}
type genesisChunkedArgs struct {
ID StrInt `json:"chunk"`
}
type (
healthArgs struct{}
statusArgs struct{}
netInfoArgs struct{}
blockchainInfoArgs struct {
MinHeight StrInt64 `json:"minHeight"`
MaxHeight StrInt64 `json:"maxHeight"`
}
)
type (
genesisArgs struct{}
genesisChunkedArgs struct {
ID StrInt `json:"chunk"`
}
)
type blockArgs struct {
Height StrInt64 `json:"height"`
}
Expand Down Expand Up @@ -67,11 +71,13 @@ type validatorsArgs struct {
Page StrInt `json:"page"`
PerPage StrInt `json:"per_page"`
}
type dumpConsensusStateArgs struct{}
type getConsensusStateArgs struct{}
type consensusParamsArgs struct {
Height StrInt64 `json:"height"`
}
type (
dumpConsensusStateArgs struct{}
getConsensusStateArgs struct{}
consensusParamsArgs struct {
Height StrInt64 `json:"height"`
}
)
type unconfirmedTxsArgs struct {
Limit StrInt `json:"limit"`
}
Expand Down
10 changes: 8 additions & 2 deletions rpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ type Server struct {
}

const (
// DefaultServerTimeout is the default global timeout for the server.
// defaultServerTimeout is the time limit for handling HTTP requests.
defaultServerTimeout = 15 * time.Second

// ReadHeaderTimeout is the timeout for reading the request headers.
ReadHeaderTimeout = 5 * time.Second
Comment on lines +46 to +47
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// ReadHeaderTimeout is the timeout for reading the request headers.
ReadHeaderTimeout = 5 * time.Second
// readHeaderTimeout is the timeout for reading the request headers.
readHeaderTimeout = 5 * time.Second

)

// Option is a function that configures the Server.
Expand Down Expand Up @@ -197,7 +200,10 @@ func (s *Server) startRPC() error {

func (s *Server) serve(listener net.Listener, handler http.Handler) error {
s.Logger.Info("serving HTTP", "listen address", listener.Addr())
s.server = http.Server{Handler: handler} // #nosec
s.server = http.Server{
Handler: handler,
ReadHeaderTimeout: ReadHeaderTimeout,
}
mtsitrin marked this conversation as resolved.
Show resolved Hide resolved
if s.config.TLSCertFile != "" && s.config.TLSKeyFile != "" {
return s.server.ServeTLS(listener, s.config.CertFile(), s.config.KeyFile())
}
Expand Down
Loading