-
Notifications
You must be signed in to change notification settings - Fork 19
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
subscribe not working #4
Comments
Before I tell you what's wrong, let me tell you that what you are trying to do, doesn't make much sense. Waiting within a request on a published message will block the request. It can be done, but it is a bad idea. To focus on the problem: you are returning a response from the subscription callback, which is discarded (the $result = [];
$mqtt = MQTT::connection();
$mqtt->subscribe('stat/xxxxxxxx/POWER', function (string $topic, string $message) use ($mqtt, &$result) {
$result['topic'] = $topic;
$result['message'] = $message;
$mqtt->interrupt();
}, 0);
$mqtt->loop(true);
return response()->json($result, 200); But I repeat myself: this makes no sense. You should not be waiting for published messages in a request. Most |
Working, Thank you for your advice. |
return empty
But on MQTT Dashboard (App android) this topic working
And publish working
The text was updated successfully, but these errors were encountered: