react-native-paho-mqtt icon indicating copy to clipboard operation
react-native-paho-mqtt copied to clipboard

My mqtt is not working when i am using the release version but it is working when i am using it in build format

Open Harshkhosla opened this issue 1 year ago • 5 comments

export const Click = (user) => { // debugger; // console.log(user, "coming hear"); return (dispatch) => { // const { authtoken, field2 } = user; // console.log(authtoken,"ekvhjwejh");

const client = new Client({ uri: 'ws://192.168.10.111:9001/ws', clientId: 'JOULS ECOTECH243546578989', storage: myStorage });
// set event handlers
client.on('connectionLost', (responseObject) => {
  if (responseObject.errorCode !== 0) {
    console.log(responseObject.errorMessage);
  }
});
const onConnect = () => {

  client.on('messageReceived', (message) => {
    console.log(message?.payloadString);
    dispatch(setAuthtoken(message?.payloadString));
  });
}

client.connect()
  .then(() => {
    // Once a connection has been made, make a subscription and send a message.
    console.log('onConnect');
    return client.subscribe('Jouls_Ecotech_User_Notifications');
  })
  .then(() => {
    const sampleee ={
      "Charging Mode": "Balanced_Mode"
    }
    const message = new Message(JSON.stringify(user));
    message.destinationName = 'Jouls_Ecotech_User_ID';
    // const sample = new Message(JSON.stringify(sampleee));
    // sample.destinationName = 'Jouls_Ecotech_User_Charging Modes';
    client.send(message);
    // client.send(sample);
  }).then(() => {
    onConnect()
  })
  .catch((responseObject) => {
    if (responseObject.errorCode !== 0) {
      console.log('onConnectionLost:' + responseObject.errorMessage);
    }
  })


//   client.onConnectionLost = onConnectionLost;
//   client.onMessageArrived = onMessageArrived;

} } my code in this the connection is happning when my app is in build form but when i release it to play store or use its release format it is giving connection error .

Harshkhosla avatar May 31 '23 13:05 Harshkhosla