Comments (4)
@wyx087 Thanks for raising the issue. The examples are just meant to be simple demos of how to get started, but I wasn't aware the subscriber gives extra characters some times—do you know why? To me it looks like the null-character should be included in the payload:
MQTT-C/examples/simple_publisher.c
Line 118 in 399361f
from mqtt-c.
The problem is most likely that not all publishers do this.
The default samples continue sessions from others, so he might be looking at that
from mqtt-c.
That's a good point. @wyx087 did you modify simple_publisher.c? If you're using simple_subscriber.c out-of-the-box on a common testing broker like https://test.mosquitto.org, the topic name is "datetime" so it's possible other peoples' publishes to "datetime" are coming back to you.
Regardless, I don't think this is a bug, but @wyx087 your approach using application_message_size
is what you should be doing.
I'm going to close this issue but feel free to reopen
from mqtt-c.
I agree, it's not a bug for the core program. The purpose of this post is just to make you aware that the examples could use some form of length limiter. Hopefully will save other novices like me from some head-scratching.
Quite possibly the problem lies with my publisher. But monitoring with Home Assistant MQTT doesn't reproduce this. Equally, HA could have implemented length limiter.
Here is debug output from my program, which is adopted from your reconnect_subscriber example.
Publisher is https://github.com/emoncms/emoncms
First print shows message as shown by your example. Second print uses the sprintf I posted earlier.
Received publish('power/export'): 06.74power/usage226.74power/usage227.22
Received publish('power/export'): '0'
Received publish('power/solar'): -00
Received publish('power/solar'): '-0'
Received publish('power/usage'): 228.86power/usage228.86power/usage227.22
Received publish('power/usage'): '228.86'
Received publish('power/export'): 06.86power/usage206.86power/usage206.86
Received publish('power/export'): '0'
Received publish('power/solar'): -00
Received publish('power/solar'): '-0'
Received publish('power/usage'): 207.8
power/usage207.86power/usage206.86
Received publish('power/usage'): '207.8'
This was recorded at nearly 9pm, export value should be solid 0. The 06.74 value throws off some calculations I do later.
from mqtt-c.
Related Issues (20)
- Previous published message not cleared HOT 1
- local persistence HOT 1
- Would reconnect_publisher be a thing? HOT 3
- Adding contex to callbacks HOT 1
- Insufficient validation of PUBLISH message HOT 2
- Possible undefined behaviour/bad memory access after reconnect HOT 2
- MQTT_ERROR_SEND_BUFFER_IS_FULL due to transient MQTT_ERROR_SOCKET_ERROR
- FPU-Trap when calculating client->typical_response_time
- mqtt_publish return value causes mqtt_error_str when not connected
- mqtt_publish seems to only send QoS 0 HOT 1
- Possible bug in MQTT_CLIENT_TRY_PACK macro
- MQTT-C Security Issue Report (mqtt_unpack_publish_response) HOT 2
- swap use of double variables to float HOT 1
- How to check the client has received a Connack from the Broker after connect() HOT 7
- how to check network connection state in inspector callback
- Signed integer overflow in `mqtt_error_str()` HOT 2
- We cannot pass the context of the program to mqtt publish_callback HOT 2
- Mingw compile error
- Memory alignment in Keil ARM Compiler (thumb instruction set)
- mqtt_connect does not generate a client.error if wrong username and/or password is provided
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 mqtt-c.