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

Add timeout for HTTP connections #2628

Merged
merged 3 commits into from
Oct 20, 2022
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
3 changes: 2 additions & 1 deletion CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@
#### Orchestrator
- [#2591](https://github.com/livepeer/go-livepeer/pull/2591) Return from transcode loop if transcode session is ended by B (@yondonfu)
- [#2592](https://github.com/livepeer/go-livepeer/pull/2592) Enable Orchestrator to set pricing by broadcaster ETH address
- [#2628](https://github.com/livepeer/go-livepeer/pull/2628) Use IdleTimeout to prevent hanging HTTP connections when B does not use O (fix "too many files open" error) (@leszko)

#### Transcoder
#### Transcoder
9 changes: 4 additions & 5 deletions server/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (

const GRPCConnectTimeout = 3 * time.Second
const GRPCTimeout = 8 * time.Second
const HTTPTimeout = 8 * time.Second

var authTokenValidPeriod = 30 * time.Minute
var discoveryAuthWebhookCacheCleanup = 5 * time.Minute
Expand Down Expand Up @@ -203,11 +204,9 @@ func StartTranscodeServer(orch Orchestrator, bind string, mux *http.ServeMux, wo

glog.Info("Listening for RPC on ", bind)
srv := http.Server{
Addr: bind,
Handler: &lp,
// XXX doesn't handle streaming RPC well; split remote transcoder RPC?
//ReadTimeout: HTTPTimeout,
//WriteTimeout: HTTPTimeout,
Addr: bind,
Handler: &lp,
IdleTimeout: HTTPTimeout,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have the other timeouts too? Maybe even just the more general Timeout? I'm not sure there's any reason for a request to take longer than that

https://medium.com/@nate510/don-t-use-go-s-default-http-client-4804cb19f779

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In general we should, but currently it would break the split O/T functionality, because /transcodeResults endpoint would also have read/write timeouts and our transcoders do not tolerate it now...

So, in general you're right, but I think to make it happen it's not a quick fix.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 Makes sense

}
return srv.ListenAndServeTLS(cert, key)
}
Expand Down