Git Product home page Git Product logo

Comments (3)

FZambia avatar FZambia commented on June 2, 2024

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.

from centrifugo.

xfourat avatar xfourat commented on June 2, 2024

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:

  • const sub = centrifuge.getSubscription("ns:channel_id", {token: token});
  • const sub = centrifuge.subscription("ns:channel_id", {token: token});

from centrifugo.

FZambia avatar FZambia commented on June 2, 2024

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.

from centrifugo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.