GithubHelp home page GithubHelp logo

hichard / mymqtt Goto Github PK

View Code? Open in Web Editor NEW
38.0 38.0 14.0 180 KB

Eclipse Paho MQTT C/C++ client for Embedded platforms.A new efficient and stable way to realize for rt-thread.

License: Eclipse Public License 1.0

C 98.56% CMake 1.04% Python 0.40%

mymqtt's People

Contributors

hichard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mymqtt's Issues

my_mqtt 断线无法重连

最近在使用这个库。但是在开发中发现一旦断线了,就一直连接不上,请问这个是什么问题呢?

mqtt 重新连接服务器时 内存增多的问题

mqtt 重新连接后 内存明显增多

msh />free
total memory: 113256
used memory : 31196
maximum allocated memory: 32536
msh />[E/at.skt.sim800] sim0 device socket(0) wait send result timeout.
[E/mqtt] [70910] send ping rc: -1
[D/mqtt.sample] inter mqtt_offline_callback! time_num:1
[D/at.dev.sim800] link_status: 1
[E/at.clnt] execute command (AT+CIPCLOSE=0) failed!
[D/mqtt] restart!
[D/mqtt.sample] inter mqtt_connect_callback!
[D/mqtt] ipv4 address port: 1883
[D/mqtt] HOST = '***********'
[I/mqtt] MQTT server connect success.
[I/mqtt] Subscribe #0 ******************* OK!
[D/mqtt.sample] inter mqtt_online_callback!
msh />free
total memory: 113256
used memory : 31612
maximum allocated memory: 32988

无法保证qos2逻辑稳定性

mqtt_cycle()函数中,有以下代码,当qos2报文到来的时候,调用deliver_message()函数去处理了,并且发送PUBREC应答报文,但是当网络状况不良的时候,服务器由于没有收到这个PUBREC应答报文的时候,服务器就会重发qos2报文,此时mqtt_cycle()函数依旧会调用deliver_message()函数去处理这个qos2报文,这样子就会处理两次报文,而不是有且只有一次qos2....

  case PUBLISH:
    {
      MQTTString topic_name;
      mqtt_message msg;
      int intQoS;
      if (MQTTDeserialize_publish(&msg.dup, &intQoS, &msg.retained, &msg.id, &topic_name,
                                  (unsigned char **)&msg.payload, (int *)&msg.payloadlen, c->readbuf, c->readbuf_size) != 1)
        goto __cycle_exit;
      msg.qos = (enum QoS)intQoS;
      deliver_message(c, &topic_name, &msg);
      if (msg.qos != QOS0)
      {
        mqtt_client_lock(c);
        if (msg.qos == QOS1)
          len = MQTTSerialize_ack(c->buf, c->buf_size, PUBACK, 0, msg.id);
        else if (msg.qos == QOS2)
          len = MQTTSerialize_ack(c->buf, c->buf_size, PUBREC, 0, msg.id);
        if (len <= 0)
          rc = PAHO_FAILURE;
        else
          rc = send_packet(c, c->buf, len);
        mqtt_client_unlock(c);
        
        if (rc == PAHO_FAILURE)
          goto __cycle_exit; // there was a problem
      }
    }
    break;

多线程使用publish导致死机

另开一个线程进行publsih的话,如果mqtt线程出现掉线重连,会出现crash,如果其他人有遇到,我可以提交一个PR,如果没人遇到那可能是我使用不当哈哈。

Fails on rt-thread 4.1.1

This repo fails on rt-thread 4.1.1, acitvity seems to be zero anyway...
../packages/mymqtt-latest/MQTTClient-C/mqtt_client.c:269:17: error: storage size of 'linger' isn't known
struct linger linger;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.