mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-14 07:26:47 +00:00
OKX: Fix authenticated websocket blocking during login (#1174)
The channels for the ws multiplexer weren't made; so any interaction with it would block. Tests passed because they invasively setup the multiplexer. There are quite a few architectural risks with this implementation pattern, such as leaking an uncancellable goro in a for-select loop. Ideally WsConnect should take a cancellable context and any selects should watch for ctx.Done() That's a very invasive and pervasive change though, so this fix is as minimal and atomic as possible. Will consider opening a PR for cancellable context or improving this multiplexer pattern.
This commit is contained in:
@@ -48,12 +48,6 @@ func TestMain(m *testing.M) {
|
||||
exchCfg.API.Credentials.Key = apiKey
|
||||
exchCfg.API.Credentials.Secret = apiSecret
|
||||
exchCfg.API.Credentials.ClientID = passphrase
|
||||
ok.WsResponseMultiplexer = wsRequestDataChannelsMultiplexer{
|
||||
WsResponseChannelsMap: make(map[string]*wsRequestInfo),
|
||||
Register: make(chan *wsRequestInfo),
|
||||
Unregister: make(chan string),
|
||||
Message: make(chan *wsIncomingData),
|
||||
}
|
||||
ok.SetDefaults()
|
||||
if apiKey != "" && apiSecret != "" && passphrase != "" {
|
||||
exchCfg.API.AuthenticatedSupport = true
|
||||
|
||||
@@ -192,6 +192,13 @@ func (ok *Okx) Setup(exch *config.Exchange) error {
|
||||
return err
|
||||
}
|
||||
|
||||
ok.WsResponseMultiplexer = wsRequestDataChannelsMultiplexer{
|
||||
WsResponseChannelsMap: make(map[string]*wsRequestInfo),
|
||||
Register: make(chan *wsRequestInfo),
|
||||
Unregister: make(chan string),
|
||||
Message: make(chan *wsIncomingData),
|
||||
}
|
||||
|
||||
wsRunningEndpoint, err := ok.API.Endpoints.GetURL(exchange.WebsocketSpot)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user