-
Notifications
You must be signed in to change notification settings - Fork 217
Resubscribing after client reconnects? #15
Comments
Hmm that's quite tricky and probably can't be accomplished right now. Connect() probably need to be changed to Observable and cannot be Completed upon connection like now. Then it should be possible to listen for connection events in subscribe of connect() and resolve them. It's pretty big change, I forgot this scenario when designing the library. |
Maybe, it could be possible to make automatic resubscriptions for wamp only. |
It's also a little connected to the WAMP library I'm using. I've increased the version of jawampa-netty in latest release (2.3.0). Just try it again to be sure, issue is still here. |
With regards to poloniex, There are two exchanges:
Which project is the recommended? |
I suppose newer which is poloniex2 |
@roeiba poloniex2 is using the websocket from the poloniex webpage and was implemented because the WAMP socket is lagging several hours behind, i highly suggest poloniex2 if you need live data. This is a problem I recognized too and we really need a solution for this. For a first workaround i would suggest to provide a callback if the websocket is closing. With such a solution we would have the ability to reconnect manually. @dozd Do you have a strategy for the closing problem on other exchanges or does this problem exist on every project? From what I've seen the reconnect on the poloniex2 is not implemented yet, is it? Its pretty ugly to debug this -.- |
@firegnome I'm not aware of this problem on other exchanges but I think it could happen there as well. I think solution is either change method |
I implemented a re-subscribe feature in NettyStreamingService. Additionally I did override the WebSocketClientHandler in poloniex2 to get the disconnect event and automatically reconnect and resubscribe the channels. I'm currently testing if this is actually working... it's a bit tedious because i have to wait for the websocket to close -.- I'm looking forward to your feedback firegnome@efff9dd |
Looks good, thanks for this! As the old wamp api had become almost unusable and xchange-poloniex2 didn't exist yet back in september, I ended up implementing a simple streamer for api2 using Tyrus (which supports reconnects). It works pretty nicely, but I might give this a try later too. |
I have been streaming tickers from Poloniex succesfully by following the example here. Works nicely, but everytime the wampclient disconnects (and automatically reconnects) I lose all my subscribtions. So I guess I should always resubscribe to getTicker when the client state changes to connected, but what is the best way to detect this? I can only see the "State changed:" log message when this happens.
Very new to RxJava, so the answer might be obvious, but I just can't seem to figure it out. Thanks!
The text was updated successfully, but these errors were encountered: