1

Currently a user logs in from my vue app which consumes a REST api. Once the user logs in I get a jwt token and get the user's information. I then store the user's info in pinia and persist state with local storage. After I get the user's information I need to initialize a MQTT client with the subscribers. Is it possible to make subscriptions after the on_connect function has been called. I have had trouble with this paho-mqtt in python. Please let me know if this is possible and how I can architect my application. Thank you.

I have tried initializing vue-mqtt in main.js but the subscriptions change base on who is logged in and thus doesn't work.

Cooder
  • 31
  • 2
  • 1
    Yes it is possible to "make subscriptions after the on_connect function has been called" (if you want an example take a look at [mqtt-json-rpc](https://github.com/rse/mqtt-json-rpc)). Unfortunately as you [have not provided any code](https://stackoverflow.com/help/how-to-ask) demonstrating the issue you are facing its difficult to comment further. – Brits Oct 30 '22 at 01:10
  • The point about `on_connect` callbacks is that you should not try and subscribe to topics **before** this is called. But you can change what topics a client is subscribed to at any time before the client is disconnected after it has been called. – hardillb Oct 30 '22 at 07:14

0 Answers0