Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
Connection lost after a few minutes later in react native

I'm working on an app using MQTT protocol & react native, I faced one problem which is when I run my app after a few minutes later it connect & disconnect several time after it closed can someone help me to solve this issue please.

Here is the log :

enter image description here

useEffect(() => {
   
    client.onConnect = onConnect;
    client.onConnectionLost = onConnectionLost;
    client.onPress = onPress;
 
      client.connect({ 


     
            onSuccess : onConnect, 
            userName: process.REACT_APP_DB_NAME,
            password: process.REACT_APP_PASSWORD,
            onFailure : onConnectionLost, 
      
          });
        
         
        if (isMounted.current) {
            fetchData();
          
        }
          return () => {
            isMounted.current = false;
          }
        
      }, [client])

const onConnect = () => {
      console.log("Connected!!!!home screen");
      setIsConnected(true);
    };
 

    const onConnectionLost = (responseObject)=> {
      if (responseObject.errorCode !== 0) {
        console.log("onConnectionLost : "+responseObject.errorMessage);
       setIsConnected(false);
      }
    }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!