-
Notifications
You must be signed in to change notification settings - Fork 146
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
OnConnect function does not get the status of the mosquito server #58
Comments
You can get the error message from the exception: <?php
try {
$c = new Mosquitto\Client();
$c->connect('localhost', 1234);
} catch (Mosquitto\Exception $e) {
var_dump($e->getCode());
var_dump($e->getMessage());
}
However you'll note that the error code is always |
@mgdm However, in the description of the onConnect method, there is a return status code which is not available for the server. |
Hi @mgdm ! Did you some change to get error code from Mosquitto? Best regards. |
Hi @mgdm ! I'v to ask the same question. Are there any changes made or planned, because there is no chance to recognize any connection error. "connect" is not throwning any exception and if the broker is unreachable there is no message in onConnect neither onDisconnect. So it's quiet unusable. Best regards and an answer would be appreciated |
Here is the code
<?php
$client = new Mosquitto\Client();
$client->onConnect(function ($rc,$message) {
print_r($rc);
});
try {
$client->connect("127.0.0.1", 1883);
$client->subscribe('test', 1);
while(true) {
$client->loopForever();
sleep(2);
}
} catch (Mosquitto\Exception $e) {
print_r($e);
}
When the mosquito server is not available, the connect method throws a Mosquitto\Exception. But the onConnect callback function can not get codes Response. So how do I get the status of the mosquito server?
The text was updated successfully, but these errors were encountered: