Skip to content
Closed
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
15 changes: 14 additions & 1 deletion node/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ import (

var rpclog = logging.Logger("rpc")

const (
// HTTP server timeout constants
readHeaderTimeout = 10 * time.Second
readTimeout = 60 * time.Second
writeTimeout = 60 * time.Second
idleTimeout = 60 * time.Second
maxHeaderBytes = 1 << 20
)

// ServeRPC serves an HTTP handler over the supplied listen multiaddr.
//
// This function spawns a goroutine to run the server, and returns immediately.
Expand All @@ -47,7 +56,11 @@ func ServeRPC(h http.Handler, id string, addr multiaddr.Multiaddr) (StopFunc, er
// Instantiate the server and start listening.
srv := &http.Server{
Handler: h,
ReadHeaderTimeout: 30 * time.Second,
ReadHeaderTimeout: readHeaderTimeout,
ReadTimeout: readTimeout,
WriteTimeout: writeTimeout,
IdleTimeout: idleTimeout,
MaxHeaderBytes: maxHeaderBytes,
BaseContext: func(listener net.Listener) context.Context {
ctx := context.Background()
ctx = metrics.AddNetworkTag(ctx)
Expand Down
Loading