GithubHelp home page GithubHelp logo

Comments (2)

scaprile avatar scaprile commented on August 23, 2024

What is 'c' ? In which module ? In which file ?
There is a MQTTCloseSession() function in MQTTClient.c in MQTTClient-C that has a parameter named 'c', which is a MQTTClient structure; there is no member named 'disconnect' in that structure. Are you using this very repo or a forked/vendor modified one?
The client does not know what a socket is, it is network agnostic, whatever you are using as a transport support has to handle the TCP connection to the broker, including opening and closing the socket (if you use a socket API) and handling network errors.
For example:

  • the Linux port has NetworkDisconnect() which closes the socket, as you can see on the sample MQTTClient-C/samples/linux/stdoutsub.c.
  • the FreeRTOS port has a 'disconnect' member in a 'Network' structure that handles that.

from paho.mqtt.embedded-c.

pavel-kamaev avatar pavel-kamaev commented on August 23, 2024

I use this repo with FreeRTOS and LwIP stack.

I do something like that:

while (1) {
  do {
    NetworkInit(&network);
    MQTTClientInit(&client, &network, 30000, sendbuf, sizeof(sendbuf), readbuf, sizeof(readbuf));
    if ((rc = NetworkConnect(&network, broker_addr, 1883)) != 0) {
      continue;
    }
// Fill connectData
    if ((rc = MQTTConnect(&client, &connectData)) != 0) {
      continue;
    }
// Subscribe
  } while (rc != SUCCESS);
  while (1) {
    if ((rc = MQTTYield(&client, 500)) != 0) {
      break;
    }
  }
}

What is the proper way to handle connection errors (reconnect to broker on error)? Should I close connection every time MQTTYield() returns negative value or FAILURE only? Is there any reason not to use disconnect callback from MQTTCloseSession()?

from paho.mqtt.embedded-c.

Related Issues (20)

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.