VictorHAS / mqtt-react-hooks

ReactJS library for Pub/Sub communication with an MQTT broker using Hooks
MIT License
91 stars 28 forks source link

Seeking for help with lost of connection: Connection Closed: 1005 #64

Open jensdenbraber opened 2 years ago

jensdenbraber commented 2 years ago

I have a react application with multiple components which are shown in a tab like structure like a browser with multiple tabs. Using mui buttons I'm able to display the corresponding tab however the MQTT connection closed with the 1005 errorcode. After trying lots of things I run out ideas so solve this.

Does someone have an idea what could be the problem?

jensdenbraber commented 2 years ago

Does nobody have this problem?

jensdenbraber commented 2 years ago

@VictorHAS do you have an idea what could cause this problem? :)

jensdenbraber commented 2 years ago

@Aposhian @andyFang94 @alexgorbatchev @turingmachine do you have an idea what could cause this problem? :)

Aposhian commented 2 years ago

My best guess is that your Connector component is getting rerendered for some reason. I would check the React dev tools and profile it to see what is getting rerendered when you switch tabs, and make sure that the Connector isn't getting rerendered.

andyFang94 commented 1 year ago

@Aposhian @andyFang94 @alexgorbatchev @turingmachine do you have an idea what could cause this problem? :)

Hello, I made this code now here to try to explain. You will need the connector around the entire application and useSubscription to get connected

mqtt-react-hooks-example