-
Notifications
You must be signed in to change notification settings - Fork 28
Mqtt is stuck in connecting state in 2.0.0 version #13
Comments
Hi there, I have the same issue and nothing bad in the logs ("New client connected from x.x.x.x as mqttjs_0773ea48 (c1, k0).") |
@VictorHAS I am getting this error when I am connecting SSR in nextjs but when I am loading this on clientside. it is working fine. |
I got some free time, I'll be looking for the solution for this. Sorry about anything, it's my first lib. @coderantongmail thanks for providing images, could you send me how is your MQTT configuration? -edit @coderantongmail also you can import like this |
Can you guys try this please? @coderantongmail , @Enigma10 and @gggard
For some reason, using this option here connects normally |
Thank you @VictorHAS , Adding options={{ keepalive: 0 }} parameter to the helped to solve this problem. But I also want to check how the library will behave if the broker stops responding, whether it will reconnect and change statuses. |
since this lib is a wrapper for Mqtt.js, it will automatically reconnect. https://github.com/mqttjs/MQTT.js#client for more informations |
If I have several components that are independent of each other, I add a subscription to a topic in the right component with the appropriate logic, but the component that was subscribed to another topic automatically receives all messages from all subscriptions. Is this normal behavior or was it intended a little differently? If I disable broker status not changed to reconnecting, this is bug. And if broker run again, mqtt is reconnect, but status in connectionStatus not change if broker is down. For example as in the screenshots below: As a result, I had to do an additional check for the topic I needed, otherwise I received a bunch of unnecessary messages that should have been only in the diagnostic component. After the second component has been destroyed, the subscription is saved all the same. It is necessary to make it possible to unsubscribe from the topic when the component is destroyed. More precisely, add the ability to unsubscribe in the library |
@coderantongmail since your comment is not directly related to this issue, I will create another one ok? |
Ok, thank`s @VictorHAS |
@VictorHAS Thanks for providing this library -- I am experiencing this issue on v2.0.2: |
Okay, I was being dumb but I'll leave this here to help future people!
It's not ideal, but now I am connecting properly |
@tom-con thanks for reporting this, i will be pinning to help other people. If you know how to solve this problem in the package, can you create a PR? unfortunately, my time is tight to make adjustments. |
@tom-con I just tested a new solution to this, with dynamic import and using ssr:false
|
@VictorHAS This works great! Thank you for experimenting and finding this solution. |
Actually I just realized something -- this causes anything that is in the DOM tree beneath the dynamically imported component to not render until the import is complete on the client. If the I suggest using a combination approach: keep both the dynamic import and the Your example:
Suggestion:
|
This is my connector code
The text was updated successfully, but these errors were encountered: