Comments (7)
Awesome, thanks. I'll have a look. Probably over the weekend.
But in general, think what might work better for you - automatic or manual updates. It's not too tough to do it manually; many of the example apps demonstrate it. But the auto/backoff algorithm is usable in most situations.
from paho.mqtt.cpp.
I haven't figured out if the C lib fires the "connection lost" callback if it gets a clean disconnect from the server (i.e. receives a DISCONNECT packet). At first I assumed it did, then I thought it didn't. Now I'm not sure. I'm currently trying to set up the test broker to figure it out and/or check the C code to confirm.
That means you may need to set an on_disconnect
handler via set_disconnected_handler()
to make sure you're always being informed when the connection is lost.
I'll confirm ASAP, since I need to resolve #458.
from paho.mqtt.cpp.
What version of the Paho C client are you using? Something that sounds just like this was recently fixed in the C v1.3.13 client.
from paho.mqtt.cpp.
Oh, actually, this may be different. What platform? What compiler/version?
I canβt say that the expected behavior would be exactly what you want. Perhaps the library might ignore an explicit request to reconnect if the automatic option is turned on? Iβd have to look at the implementation.
But either way, it definitely should never hard crash.
from paho.mqtt.cpp.
As of this morning, I've reproduced it on two separate OS's, both on ARM platforms. If you want to reproduce, I just modified the multithr_pub_sub.cpp
example (attached with my changes) - multithr_pubsub.txt
MacOS (just tested this morning)
- Using MacPorts with MQTTVersion
1.3.13
- Compiler is clang
$ clang --version
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin23.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
- Backtrace:
* thread #4, stop reason = signal SIGABRT
* frame #0: 0x000000018ba0111c libsystem_kernel.dylib`__pthread_kill + 8
frame #1: 0x000000018ba38cc0 libsystem_pthread.dylib`pthread_kill + 288
frame #2: 0x000000018b948a40 libsystem_c.dylib`abort + 180
frame #3: 0x000000018b9f06d8 libc++abi.dylib`abort_message + 132
frame #4: 0x000000018b9e07ac libc++abi.dylib`demangling_terminate_handler() + 320
frame #5: 0x000000018b68b8a4 libobjc.A.dylib`_objc_terminate() + 160
frame #6: 0x000000018b9efa9c libc++abi.dylib`std::__terminate(void (*)()) + 16
frame #7: 0x000000018b9f2a48 libc++abi.dylib`__cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 36
frame #8: 0x000000018b9f29f4 libc++abi.dylib`__cxa_throw + 140
frame #9: 0x00000001004c7e94 libpaho-mqttpp3.1.dylib`mqtt::async_client::reconnect() + 324
frame #10: 0x0000000100004588 harbor.out`publisher_func(std::__1::shared_ptr<mqtt::async_client>, std::__1::shared_ptr<multithr_counter>) + 292
frame #11: 0x000000010000e540 harbor.out`decltype(static_cast<void (*>(fp)(static_cast<std::__1::shared_ptr<mqtt::async_client>>(fp0), static_cast<std::__1::shared_ptr<multithr_counter>>(fp0))) std::__1::__invoke<void (*)(std::__1::shared_ptr<mqtt::async_client>, std::__1::shared_ptr<multithr_counter>), std::__1::shared_ptr<mqtt::async_client>, std::__1::shared_ptr<multithr_counter> >(void (*&&)(std::__1::shared_ptr<mqtt::async_client>, std::__1::shared_ptr<multithr_counter>), std::__1::shared_ptr<mqtt::async_client>&&, std::__1::shared_ptr<multithr_counter>&&) + 84
frame #12: 0x000000010000e4a0 harbor.out`void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(std::__1::shared_ptr<mqtt::async_client>, std::__1::shared_ptr<multithr_counter>), std::__1::shared_ptr<mqtt::async_client>, std::__1::shared_ptr<multithr_counter>, 2ul, 3ul>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(std::__1::shared_ptr<mqtt::async_client>, std::__1::shared_ptr<multithr_counter>), std::__1::shared_ptr<mqtt::async_client>, std::__1::shared_ptr<multithr_counter> >&, std::__1::__tuple_indices<2ul, 3ul>) + 76
frame #13: 0x000000010000d91c harbor.out`void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(std::__1::shared_ptr<mqtt::async_client>, std::__1::shared_ptr<multithr_counter>), std::__1::shared_ptr<mqtt::async_client>, std::__1::shared_ptr<multithr_counter> > >(void*) + 84
frame #14: 0x000000018ba39034 libsystem_pthread.dylib`_pthread_start + 136
Linux (initial PR) - Debian Bullseye
- running off of master branch (I probably shouldn't, and will likely address after this to run on 1.3.13 or greater)
- Building with CMake & clang under the hood, version is what is provided in Bullseye:
[bullseye (oldstable)](https://packages.debian.org/bullseye/clang) (devel): C, C++ and Objective-C compiler (LLVM based), clang binary
1:11.0-51+nmu5: amd64 arm64 armel armhf i386 mips64el mipsel ppc64el s390x
from paho.mqtt.cpp.
Sounds good, thanks! I was having some issues with the connection_lost callback being called for manual (yet autoreconnect working) but I'll take another stab at it.
from paho.mqtt.cpp.
Thanks! I'll look into implementing that
from paho.mqtt.cpp.
Related Issues (20)
- Why is this project under Eclipse v1.0 when paho.mqtt.c is under Eclipse v2.0? HOT 1
- Building paho.mqtt.cpp: cmake doesn't pick up my c++ compiler correctly. HOT 4
- Homebrew Installation HOT 1
- Connect failed, more to try HOT 1
- SSL_read() Segmentation fault
- Build with PAHO_WITH_MQTT_C is broken HOT 3
- broker(emqx) already support QUIC, and i Hope client also supports the Quic protocol HOT 1
- arm cross get error HOT 5
- Add getter for the connect_options object (connOpts_) in async_client
- Operation not permitted on try_consume_message async HOT 1
- Base64TestOpenSSL giving problem and how to use only paho-mqtt3as libraray project in visual studio HOT 1
- Cross compilation of paho.mqtt.cpp HOT 9
- cmake issue in Docker container HOT 2
- error in install_paho_mqtt_c.sh in the installation process of the latest version of paho.mqtt.cpp HOT 1
- ThreadSanitizer: lock-order-inversion (potential deadlock) paho 1.2.0
- Linker-Error when compiling with v1.3.2 HOT 5
- connect_options_builder doesn't propagate always properties HOT 5
- Rustls C++ binding into the paho-mqtt HOT 1
- Build error in Xcode project HOT 2
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 paho.mqtt.cpp.