forresthopkinsa / StompProtocolAndroid

Websockets on Android
MIT License
11 stars 4 forks source link

It's impossible to subscribe to topic after unsubscribing #3

Closed stairs closed 6 years ago

stairs commented 6 years ago

Topics are not removed from mTopics map on unsubscribe. Therefore we get "Attempted to subscribe to already-subscribed path!" error when trying to subscribe again. The fix seems to be pretty easy. Though I would still suggest automatic resubscribing to topics when sockets are connected.

forresthopkinsa commented 6 years ago

Thanks for finding this! I'll publish a fix tomorrow.

stairs commented 6 years ago

Many thanks for a quick response!

forresthopkinsa commented 6 years ago

Sorry I didn't publish a fix on Friday, I forgot that it wasn't a workday. I'll release a fix tomorrow, once I'm back at my work computer. Sorry for the wait.

stairs commented 6 years ago

NP. Thanks for letting us know!

forresthopkinsa commented 6 years ago

Let me know if that fix doesn't work

stairs commented 6 years ago

There is a small problem with it. You're removing destination before fetching topic id. Therefore it will always result in an error when unsubscribing with null id.

forresthopkinsa commented 6 years ago

Okay, yeah, I've started testing that commit and I see the problem. That was a dumb move on my part, I should have been paying more attention haha

forresthopkinsa commented 6 years ago

I've been pretty busy at work -- can you let me know whether this works for you? Committing the obvious fix now...

stairs commented 6 years ago

Thanks! I have no problem with resubscribing now. However, now after each re-connect, I receive more and more duplicate messages somehow :D I'll try to understand how share() operator works and come up with a fix. Please, advise if you see the solution at once.

stairs commented 6 years ago

Got it. We just don't disconnect from messages() on disconnect(). Therefore each new connect() will result in callSubscribers() executed as many times as connect() was called.

stairs commented 6 years ago

If you can give an access I'll create a PR with the fix.

forresthopkinsa commented 6 years ago

Duplicate messages? Interesting. I've seen that before, but I had fixed it then. Good find!

Could you make a separate issue for it? Then we can work on a PR. Thanks!