Closed xfourat closed 9 months ago
Hello @xfourat , this happens since you are subscribing to the same channel ns:channel_id
using server-side subscription (by setting channels
in token) and using client-side subscription (centrifuge.newSubscription("ns:channel_id", {token: token});
).
Think you misunderstood what channels
in connection token mean. Probably you decided that it's allowed channel to subscribe (permissions) – but it's not. When you have channels
in token Centrifugo subscribes client to these channels automatically at the moment of connection establishment. So client-side subscription then receives already subscribed
- because one client can't subscribes to the same channel twice.
Thank you @FZambia
If centrifugo subscribes client to these channels automatically at the moment of connection establishment then how can have the sub object client side to use it for receiving messages ?
I have tried the followings without success:
Check out this tutorial for example: https://centrifugal.dev/docs/tutorial/intro - it shows how to use subscription object. Just do not use server-side subscriptions at all (i.e. avoid using channels
in connection token) - and subscribe with properly constructed subscription token. And it will work. If you still have questions after reading tutorial - please reach out in communities https://centrifugal.dev/docs/getting-started/community - and I'll try to help.
Describe the bug. A clear and concise description of what the bug is.
I have a centrifuge-js client connecting just fine on first subscription everything goes fine and I can push some messages to the client, if the page is refereshed there will be no possible way to re-subscribe (even with a different jwt token on same channel).
Versions
Centrifugo version is 5.2.2 Client library used is centrifuge-js of version 5.0.1 Operating system is docker container
Steps to Reproduce How can the bug be triggered?
I have a centrifuge-js client connecting just fine on first subscription everything goes fine and I can push some messages to the client.
The issue begins when I referesh the page:
Expected behavior What output or behaviour were you expecting instead?
I'm expecting the client to reconnect and resubscribe with no issue.
Code Snippets A minimum viable code snippet can be useful.
fyi I'm generating jwt this way: