Comments (4)
You can know MQTT level status as follows:
First, call recv(), then you can get packet_variant as the CompletionToken of the recv().
async_mqtt/include/async_mqtt/packet/packet_variant.hpp
Lines 184 to 215 in 9a9160c
The index 0 of the packet_variant is system_error.
If connection is lost, then the system_error is set.
For convinience, packet_variant has operator bool().
async_mqtt/include/async_mqtt/packet/packet_variant.hpp
Lines 179 to 181 in 9a9160c
If you want to know the reason of connection lost, you can get system_error from the packet_variant, then call .what()
function.
from async_mqtt.
My problem is that I want to check weather the connection is open while I am actively receiving in another place in the program. This causes me to not be able to initiate another receive.
from async_mqtt.
You can store the result of recv() in your application as a flag.
I guess that you would expect something like bool endpoint::connected()
. But there is no such function because it is not a good idea.
async_mqtt doesn't own io_context. Just refer it.
So how to call io_context::run() is client's responsibility. It could call from different thread or multiple threads.
In this case the return valur of connected()
is unreliable.
if (ep.connected()) {
// could have already been disconnected here
}
When the status flag is reliable ? Only application developper knows it.
So it should be implemented by application side, not in the library.
from async_mqtt.
I understand, thanks for the response.
from async_mqtt.
Related Issues (20)
- Message Poller HOT 3
- Could not compile under Ubuntu 20.04 HOT 6
- broker auth logic doesn't work well for delivery HOT 1
- Coverage error HOT 1
- FYI, c++20 coroutines example HOT 2
- Send doesn't queue messages and incorrectly reports status of messages. HOT 14
- Supporting async when filtering. HOT 9
- Supporting async when filtering. HOT 1
- Publisher and Subscriber in the same MQTT client HOT 12
- [OpenSSL] Missing dependency in vcpkg port HOT 11
- Receiving a packet then "get"-ing that packet. HOT 12
- Access the value of Session Expiry Interval. HOT 2
- Calling recv with filter HOT 1
- Reason codes HOT 2
- How to properly use acquire_packet_id together with C++ 20 coroutines? HOT 4
- Nullpointer dereference on connected, moved constructed endpoint HOT 3
- Using MQTT client with std::optional. HOT 2
- Build error: "use of deleted function" HOT 2
- SHA library HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from async_mqtt.