-
Notifications
You must be signed in to change notification settings - Fork 820
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
websocket/gateio: Support multi connection management and integrate with GateIO #1580
Conversation
…larity on purpose. Change connections map to point to candidate to track subscriptions for future dynamic connections holder and drop struct ConnectionDetails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll only offer very light commentary right now.
There are things I'd do differently from this first look, but it doesn't work to comment in that way because that could blow out having an implementation where this looks to try and minimise the amount of changes while having backwards compatability. Also, this works
I'll try and focus on things to fix up and any holes I find
…le to echo back ws data as it can be easily reviewed _test file side.
…ad of waiting for a time period, add sleep inline with echo handler as this is really quick and wanted to ensure that latency is handing correctly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing those issues! I think there's a potential double-shut/close happening
|
||
// monitorTraffic monitors to see if there has been traffic within the trafficTimeout time window. If there is no traffic | ||
// the connection is shutdown and will be reconnected by the connectionMonitor routine. | ||
func (w *Websocket) monitorTraffic() func() bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried simulating a disconnect on Binance and got the following:
panic: close of closed channel
goroutine 950 [running]:
github.com/thrasher-corp/gocryptotrader/exchanges/stream.(*WebsocketConnection).Shutdown(0x14000b12000)
/Users/WIF/go/src/github.com/thrasher-corp/gocryptotrader/exchanges/stream/websocket_connection.go:275 +0x70
github.com/thrasher-corp/gocryptotrader/exchanges/stream.(*Websocket).shutdown(0x14000264800)
/Users/WIF/go/src/github.com/thrasher-corp/gocryptotrader/exchanges/stream/websocket.go:553 +0x364
github.com/thrasher-corp/gocryptotrader/exchanges/stream.(*Websocket).Shutdown(0x0?)
/Users/WIF/go/src/github.com/thrasher-corp/gocryptotrader/exchanges/stream/websocket.go:512 +0xb8
github.com/thrasher-corp/gocryptotrader/exchanges/stream.(*Websocket).observeTraffic.func1()
/Users/WIF/go/src/github.com/thrasher-corp/gocryptotrader/exchanges/stream/websocket.go:1233 +0x24
created by github.com/thrasher-corp/gocryptotrader/exchanges/stream.(*Websocket).observeTraffic in goroutine 427
/Users/WIF/go/src/github.com/thrasher-corp/gocryptotrader/exchanges/stream/websocket.go:1232 +0x1b4
exit status 2
This does not occur on master
branch. I have not been able to re-do this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a different recreation on closing the application. In this instance I had both GateIO and Binance enabled
^C[INFO] | SYNC | 30/09/2024 12:09:56 | GateIO websocket BTC-USDT SPOT ORDERBOOK: Bids len: 1 Amount: 2.933270 BTC. Total value: 189864.407233 Asks len: 1 Amount: 0.045910 BTC. Total value: 2971.66248
[INFO] | LOG | 30/09/2024 12:09:56 | Captured interrupt, shutdown requested.
[DEBUG] | LOG | 30/09/2024 12:09:56 | Engine shutting down..
[DEBUG] | ORDER | 30/09/2024 12:09:56 | Order manager shutting down...
[DEBUG] | PORTFOLIO | 30/09/2024 12:09:56 | Portfolio manager shutting down...
[DEBUG] | CONNECTION | 30/09/2024 12:09:56 | Connection manager shutting down...
[DEBUG] | CONNECTION | 30/09/2024 12:09:56 | Connection manager stopped.
[DEBUG] | PORTFOLIO | 30/09/2024 12:09:56 | Portfolio manager shutdown.
[DEBUG] | ORDER | 30/09/2024 12:09:56 | Order manager shutdown.
[DEBUG] | DISPATCH | 30/09/2024 12:09:56 | Dispatch manager shutting down...
[DEBUG] | DISPATCH | 30/09/2024 12:09:56 | Dispatch manager shutdown
[DEBUG] | EXCHANGE | 30/09/2024 12:09:56 | Currency state manager shutting down...
[DEBUG] | EXCHANGE | 30/09/2024 12:09:56 | Currency state manager shutdown.
panic: close of closed channel
goroutine 677 [running]:
github.com/thrasher-corp/gocryptotrader/exchanges/stream.(*WebsocketConnection).Shutdown(0x14000c06000)
/Users/WIF/go/src/github.com/thrasher-corp/gocryptotrader/exchanges/stream/websocket_connection.go:275 +0x70
github.com/thrasher-corp/gocryptotrader/exchanges/stream.(*Websocket).shutdown(0x140001fc800)
/Users/WIF/go/src/github.com/thrasher-corp/gocryptotrader/exchanges/stream/websocket.go:553 +0x364
github.com/thrasher-corp/gocryptotrader/exchanges/stream.(*Websocket).Shutdown(0x14000406be0?)
/Users/WIF/go/src/github.com/thrasher-corp/gocryptotrader/exchanges/stream/websocket.go:512 +0xb8
github.com/thrasher-corp/gocryptotrader/exchanges.(*Base).Shutdown(0x1400035a008)
/Users/WIF/go/src/github.com/thrasher-corp/gocryptotrader/exchanges/exchange.go:1644 +0x2c
github.com/thrasher-corp/gocryptotrader/engine.(*ExchangeManager).Shutdown.func1(0x14000cfe040, 0x14000cfe030, {0x1017f2e20, 0x1400035a008})
/Users/WIF/go/src/github.com/thrasher-corp/gocryptotrader/engine/exchange_manager.go:159 +0x3c
created by github.com/thrasher-corp/gocryptotrader/engine.(*ExchangeManager).Shutdown in goroutine 1
/Users/WIF/go/src/github.com/thrasher-corp/gocryptotrader/engine/exchange_manager.go:158 +0x1f8
exit status 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Been testing this for a few hours and appears to be working well! Just some unused vars with the changes of this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making those changes!
WebSocket
Multiple Connections for Asset Endpoints
Connection-Coupled Functionality
Reader Routine in Streaming Package
Context Awareness
DialContext
method toWebsocketConnection
to leverage the supported context.Gate.io Enhancements
WebSocket Support
Bug Fixes
generateDeliveryFuturesPayload
where different settlements were handled incorrectly.🐛 fix:
Type of change
Please delete options that are not relevant and add an
x
in[]
as item is complete.How has this been tested
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration and
also consider improving test coverage whilst working on a certain feature or package.
Checklist