mqtt-react-hooks icon indicating copy to clipboard operation
mqtt-react-hooks copied to clipboard

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

Open jensdenbraber opened this issue 2 years ago • 5 comments

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?

  • When I place a alert in the onclick() in stead of the switch tab function the connection remained open and I can send messages using a switch button on the already displayed tab

jensdenbraber avatar Aug 05 '22 11:08 jensdenbraber

Does nobody have this problem?

jensdenbraber avatar Aug 11 '22 19:08 jensdenbraber

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

jensdenbraber avatar Aug 18 '22 11:08 jensdenbraber

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

jensdenbraber avatar Aug 19 '22 13:08 jensdenbraber

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.

Aposhian avatar Aug 23 '22 19:08 Aposhian

@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

andyFang94 avatar Dec 13 '22 04:12 andyFang94