mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
Websocket reconnection fix (#541)
* Adds potential fix for websocket reconnection failure * Addr tests, we now don't return an error, this allows us to reuse existing if still in operation. * update depends && go mod tidy * adds in channel direction for parameter * Add full subscriber function, increased test coverage, initiate go routine after calling routine instance check in connection monitor * fix linter issue * use protected methods for setting field variables * removed function, added tests * lock sub manipulation * fix linter issue * Added in transport idleconnection timeout to fix MACOS reconnection issue when all idle connections are consuming resources * used protected methods to set underlying fields * set variable via time.Duration param * Added in lock around field variable in test * Addr thrasher nits and expanded exchange tests * Fix test * Addr glorious nits * go mod tidy * Add a larger timeout for traffic monitor if the test runs slow
This commit is contained in:
@@ -51,10 +51,18 @@ func initialiseHTTPClient() {
|
||||
}
|
||||
}
|
||||
|
||||
// NewHTTPClientWithTimeout initialises a new HTTP client with the specified
|
||||
// timeout duration
|
||||
// NewHTTPClientWithTimeout initialises a new HTTP client and its underlying
|
||||
// transport IdleConnTimeout with the specified timeout duration
|
||||
func NewHTTPClientWithTimeout(t time.Duration) *http.Client {
|
||||
h := &http.Client{Timeout: t}
|
||||
tr := &http.Transport{
|
||||
// Added IdleConnTimeout to reduce the time of idle connections which
|
||||
// could potentially slow macOS reconnection when there is a sudden
|
||||
// network disconnection/issue
|
||||
IdleConnTimeout: t,
|
||||
}
|
||||
h := &http.Client{
|
||||
Transport: tr,
|
||||
Timeout: t}
|
||||
return h
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user