Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loopforever causes issue when ble gateway is not connected #107

Open
nishitmodi2591 opened this issue May 29, 2019 · 0 comments
Open

loopforever causes issue when ble gateway is not connected #107

nishitmodi2591 opened this issue May 29, 2019 · 0 comments

Comments

@nishitmodi2591
Copy link

The code works fine when the BLE gateway is on. Whenever the BLE gateway is off it stops working and doesn't even give connection error.

Here is my code:

try {
    $mqttclient = new \Mosquitto\Client;
    
    $mqttclient->onConnect(function() use ($mqttclient, $gateway_topic)
    {
        $mqttclient->subscribe($gateway_topic, 0);
    });

    $mqttclient->onMessage(function($message) use($mqttclient)
    {
        $this->DataParse($message);
    });

    if(!empty($username) && !empty($password))
    {
        $mqttclient->setCredentials($username, $password);
    }

    $mqttclient->connect($mqtt_server_host, $mqtt_server_port, 60);
    
    $mqttclient->loopforever();

} catch (Exception $e) {
    writeException($e);
}

Please suggest how it can be resolved.

@nishitmodi2591 nishitmodi2591 changed the title loopforever causes issue when server is not connected loopforever causes issue when ble gateway is not connected May 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant