Skip to content

Commit

Permalink
Merge pull request #469 from gzliudan/http-server-timeout
Browse files Browse the repository at this point in the history
add http.TimeoutHandler for rpc http server
  • Loading branch information
gzliudan committed Mar 4, 2024
2 parents 753729c + 7bd39e6 commit 5223454
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rpc/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,12 @@ func NewHTTPServer(cors []string, vhosts []string, srv *Server, writeTimeout tim
// Wrap the CORS-handler within a host-handler
handler := newCorsHandler(srv, cors)
handler = newVHostHandler(vhosts, handler)
handler = http.TimeoutHandler(handler, writeTimeout, `{"error":"http server timeout"}`)
log.Info("NewHTTPServer", "writeTimeout", writeTimeout)
return &http.Server{
Handler: handler,
ReadTimeout: 5 * time.Second,
WriteTimeout: writeTimeout,
WriteTimeout: writeTimeout + time.Second,
IdleTimeout: 120 * time.Second,
}
}
Expand Down

0 comments on commit 5223454

Please sign in to comment.