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

Disable connection caching for http clients in both node and client #181

Merged
merged 1 commit into from Feb 26, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions ip/rest_resolver.go
Expand Up @@ -23,6 +23,11 @@ func NewResolverWithTimeout(timeout time.Duration) Resolver {
return &clientRest{
httpClient: http.Client{
Timeout: timeout,
Transport: &http.Transport{
//dont cache tcp connections - first requests after state change (direct -> tunneled and vice versa) will always fail
//as stale tcp states are not closed after switch. Probably some kind of CloseIdleConnections will help in the future
DisableKeepAlives: true,
},
},
}
}
Expand Down
5 changes: 4 additions & 1 deletion server/mysterium_api.go
Expand Up @@ -28,7 +28,10 @@ type mysteriumAPI struct {
func NewClient() Client {
return &mysteriumAPI{
&http.Client{
Transport: &http.Transport{},
Transport: &http.Transport{
//Don't reuse tcp connections for request - see ip/rest_resolver.go for details
DisableKeepAlives: true,
},
},
}
}
Expand Down