使用 libmosquitto 遇到的几个问题 - yanbin's Blog

使用 libmosquitto 遇到的几个问题

yanbin posted @ 2015年3月15日 22:34 in Networking with tags Networking protocol mqtt libmosquitto , 7328 阅读
1. 使用 libmosquitto 时必须要调用 mosquitto_loop_forever() 或者 mosquitto_loop();
 
2. mosquitto_loop_forever(); mosquitto_loop() 的第三个参数 max_packets 目前并没有使用,
    但是为了保持兼容性,必须设置为 1.
 
3. mosquitto_loop_start() 并不是在 thread 中调用,而是会启动一个 thread 处理 network  traffic, 
    称为 network thread; 同样的 mosquitto_loop_stop() 不是一定要在 thread 中调用,
    而是结束之前通过 mosquitto_loop_start() 创建的 network thread,
    mosquitto_loop_stop() 会等待 network thread 结束,而为了让 network thread 结束,
    又必须提前调用 mosquitto_disconnect(),
    不过可以通过设置 mosquitto_loop_stop() 的第二参数来强制 network thread 结束;

 
4.  注册 will message 同时指定 will topic。mosquitto_will_set() 的第二个参数就是指定 will topic 的。
     这就是 mqtt 里所说的 will message 有相应的 topic,  mosquitto_sub, mosquitto_pub 都有参数,
     可以指定 will topic: --will-topic;
 
5. 如果不使用 mosquitto_loop() 或者 mosquitto_loop_forever() 可以使用:
    (a) mosquitto_socket() 获取 connect socket handle;
    (b) 使用 select() 查询 socket handle 可读/可写;
    (c) 如果 select() 返回可读,mosquitto_read() 用来读取 message;
    (d) 如果返回可写,mosquitto_write() 用来发送 message;
    (e) 如果超时 mosquitto_loop_misc() 用来执行一些杂项;
 
6. libmosquitto 中 mosquitto_user_data_set() 可以设置 userdata,
    也可以在 mosquitto_new() 初始化时指定 userdata; 
    但是并没有接口获得 userdata; 毕竟 uesrdata 是外部数据,user 自己维护 userdata,
    当然应该知道指定给 mosquitto object 的 userdata 是哪一个。
 
7.保证 libmosquitto 和/或 mosquitto 版本一致。
   mosquitto-1.3.x 与 mosquitto-1.4 有兼容性问题。
   客户端使用中级 CA 签发的证书与 broker 建立 ssl 连接时,会有 tlsv1 alert unknown ca error.

 

Avatar_small
PSC Result Barisal B 说:
2022年9月04日 16:51

Government of the People’s Republic of Bangladesh, Directorate of Primary Education (DPE), is going to announce PSC Result 2022 in student wide on 30th December 2022 for all divisional Grade 5 exam result with Ebtedayee Result 2022 for annual final terminal examinations, The Primary School Certificate Examination Result 2022 will be announced for both of General and Madhrsah students in division wise to all education board known as Prathomik Somaponi Result 2022. PSC Result Barisal BoardThe DPE has successfully conducted the class 5th grade PSC and Ebtedayee Examination tests from 17th to 24th November 2022 under all education boards of Dhaka, Chittagong, Comilla, Rajshahi, Sylhet, Barisal, Jessore, Dinajpur and Madrasah Board, and the DPE Grade-5 exams are successfully conducted at all 7,194 centers across the country.

Avatar_small
charlly 说:
2023年1月04日 13:29

There are several problems that can be encountered when using the libmosquitto library. One problem is that the library can be difficult to install. Another problem is that the library can be slow, making it difficult to use for real-time applications. Finally, the documentation for the cbd oil for pain library can be difficult to understand, making it difficult to use for development.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter
Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee