mqttc | mqtt client written in c
kandi X-RAY | mqttc Summary
kandi X-RAY | mqttc Summary
mqtt client written in c language.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of mqttc
mqttc Key Features
mqttc Examples and Code Snippets
Community Discussions
Trending Discussions on mqttc
QUESTION
I am trying to send messages from one client to another using MQTT, both are publishers and subscribers. When QoS = 1, the messages are sent but sometimes duplicated. However, when I use QoS = 2, the messages are apparently not sent. Each client sends 4 messages each round, the payload is a chunk of a biggest bytearray.
Code for the publisher:
...ANSWER
Answered 2021-Apr-07 at 18:18The problem here is that AWS IoT Core only allows QoS 0 and 1. Therefore the messages won't be sent if they have QoS=2.
QUESTION
Using paho-mqtt and trying to have it receive queued messages. The broker I'm using is emqx 4.2.2 and this is my script:
...ANSWER
Answered 2020-Dec-18 at 04:56QOS only works if the client is SUBSCRIBEd...if you want to receive messages before you are Subscribed, you need to PUBLISH messages with the Retain flag set...and then you only get the last message that was sent. If you really need to get multiple messages, then you need to use something like AMQ, and not MQTT.
QUESTION
I am using paho.mqtt library to connect with aws iot core but i am not able to connect and i am getting following error
ssl.SSLError: [X509] no certificate or crl found (_ssl.c:4062)
can anyone please help me to figure it out.
...ANSWER
Answered 2020-Sep-08 at 12:51caPath is certain to be incorrect. It needs to be the Amazon root ca which you can google.
QUESTION
I got my RaspberryPi registered as a Thing in Aws IoT.
Im executing this python script:
...ANSWER
Answered 2020-Jun-26 at 10:10I figured out what the problem was:
I did not know that I have to attach the thing and the policy to a certificate. That seems like it was the problem, now I am getting the messages straight to my test console.
If someone runs into this issue, check out this Blog Entry which helped me fix it.
QUESTION
I'm struggling understanding a "weird" behavior of my simple script. Basically, it works as expected if time.sleep() is set as 60s but as soon as I put a value above 90 (90 is the limit apparently in my case), the loop doesn't work properly. I discovered this when I was trying to pause the script for 3 mins.
Here's my script
...ANSWER
Answered 2020-Jun-18 at 20:44The MQTT client uses a network thread to handle a number of different aspects of the connection to the broker.
Firstly, it handles sending ping request to the broker in order to keep the connection alive. The default period for the keepalive period is 60 seconds. The connection will be dropped by the broker if it does not receive any messages in 1.5 times this value, which just happens to be 90 seconds.
Secondly, the thread handles any incoming messages that the client may have subscribed to.
Thirdly, if you try to publish a message that is bigger than the MTU of the network link, calling mqttc.publish()
will only send the first packet and the loop is needed to send the rest of the payload.
There are 2 ways to run the network tasks.
- As you have found, you can start a separate thread with the
mqttc.loop_start()
- The other option is to call
mqttc.loop()
within your own while loop
QUESTION
I need to read a csv file has a list of objects to then do a json.dump and send row by row in a 30 seconds interval. I've got this but it is not working well, it sends a row but it is not the first and after 30 seconds stops for some reason.
...ANSWER
Answered 2020-May-28 at 12:46Your indentation is wrong, you are only adding the last record to data
because data.append(d)
is outside the first for-loop
QUESTION
Why do I get this error?
Mysql.connector.errors.DatabaseError: 2003 (HY000): Can't connect to MySQL server n '3.XX.XXX.89' (110)
I am collecting data from MQTT broker and storing it in a MySQL database. For subscribing to the topics on MQTT broker, I am using Paho MQTT client and for connecting to the MySQL database server, I am using MySQL python connector. I run this python script in the background continuously on Amazon EC2 Ubuntu instance (Virtual Server):
...ANSWER
Answered 2020-May-22 at 11:21Connections between clients (like your python program) and MySQL don't stay open forever when they're not in use. MySQL drops connections when its wait_timeout
, or interactive_timeout
, expires.
It sounds like your program works all day and sleeps all night (like the lumberjack in the Monty Python schtick). When it wakes up it has no connection to the database because MySQL closed it.
What can you do about this? In my order of preference:
Right before your program handles each queued item, perform a no-op operation like
SELECT 1;
. If that operation throws an exception, reopen the database connection. This is a good solution because it makes your application more resilient if the MySQL database server must be restarted. Sometimes cloud providers (AWS, Azure, Digital Ocean, others) have to take host machines out of service. When they do that they bounce customer virtual machines so they can start on new host machines. If you're lucky they warn you first.Update your program so it closes its database connection when its queue of work becomes empty, and reopens it when it has work to do.
Once every so often (a minute?) do a no-op
SELECT 1;
as a keepalive so MySQL won't close the connection.Change the
wait_timeout
value to something long enough. This sets it to one week.
QUESTION
I have created an MQTT class. It does connect fine and publishes the "Online" message upon connection. However something is wrong with the on_message method, as it starts but gets stuck on splitting the payload
...ANSWER
Answered 2020-Feb-14 at 14:29The issue lies with understanding the msg.payload format.
While print(msg.payload) returns a legible text, msg.payload is not a string but ASCII code. After converting msg.payload from ASCII to a string, the .split function can be used. Here is the working conversion for the mqtt payload.
QUESTION
How I can use callback function from QThread?
Callback function on_message does not print any data. In run() I connect to mqtt-broker and subscribe on topic. on_message must work when I get new message.
Example simple QT app. Change value event connected with simple QLCD. Subscription topic took from dashboard
...ANSWER
Answered 2020-Jan-28 at 15:00It is not necessary to use threads, just follow the logic of Qt: let's use signals. In the following code I show an advance of the library of an MQTT client that I am implementing that at least up to now implements what you want, in next days I will add more functionalities.
QUESTION
I'm struggling with exposing Mosquitto that I setup on my Centos7 homeserver to the outside internet through my router.
Mosquitto runs fine on my localhost and post 1883 on the homeserver. I am able to pub/sub, and it is listening on the port as 127.0.0.1:1883 (tcp)
My home router has a dynamic IP (for now), say 76.43.150.206. On the router I port forwarded 1883 as both internal/external ports to my home server, say 192.168.1.100.
In the mosquitto.conf file, I have one simply line "listener 1883 76.43.150.206".
When I then attempt to pub/sub using a python client on an external computer as mqttc.connect("76.43.150.206", 1883), it says connection refused.
Any hints on what I'm doing wrong or how to get it working? BTW, my understanding of this setup is very basic and I've pretty much been going off blogs.
...ANSWER
Answered 2017-Jul-22 at 23:48You should not put the external address into the mosquitto config file.
You should probably not even have a listen
line at all as mosquitto will bind to all available IP addresses on the machine it's running with the default port (1883).
If you really must use the listen
directive (e.g. in order to set up SSL) then it should be configured with the internal IP address of the machine running the broker, in this case 192.168.1.100
and with a different port number so it does not clash with the default
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install mqttc
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page