Coder Social home page Coder Social logo

Comments (6)

knolleary avatar knolleary commented on May 24, 2024

The rc=-4 means the client connected, but the server didn't respond to the connect request (http://knolleary.github.io/pubsubclient/api.html#state). This usually indicates the broker you're running doesn't support the 3.1.1 version of MQTT so doesn't know how to respond.

You should either upgrade your broker (assuming its mosquitto, you need at least v1.3, although the latest available is 1.4.3.

Otherwise, change the MQTT_VERSION header in PubSubClient.h to switch the library to use MQTT 3.1.

from pubsubclient.

noemark1 avatar noemark1 commented on May 24, 2024

I tried changing the MQTT_VERSION header in PubSubClient.h to use MQTT 3.1 by commenting out the 3.1.1 line and removing the comment from 3.1. I restarted IDE and recompiled - same result. How do I find out what version of mosquitto I am running on the Pi? I installed it a few days ago using sudo apt-get install mosquitto mosquitto-clients python-mosquitto

Many thanks,

-Mark

from pubsubclient.

knolleary avatar knolleary commented on May 24, 2024

Running:
$ dpkg -l mosquitto

should tell you something.

I haven't got a Pi to hand at the moment to check, but I suspect the version in the repositories may be slightly out of date. Some good instructions for installing latest/greatest here: http://jpmens.net/2013/09/01/installing-mosquitto-on-a-raspberry-pi/

from pubsubclient.

noemark1 avatar noemark1 commented on May 24, 2024

It claims it is running v 0.15, which is 3.1 compatible. I am trying to download the newest version from the server at the link you provided me above, but the server is hanging. Will try again later.

While I have you here , what are the other likely reasons for the -4 error?

Thank you for your help, as I am a relatively inexperienced user of Linux and the Arduino platform.

Many thanks,

-Mark

from pubsubclient.

knolleary avatar knolleary commented on May 24, 2024

Hmm, not sure what package version 0.15 maps to in terms of actual mosquitto version. Have a look under /var/log/ for any mosquitto related log files - it logs its version number on start up.

This is the only concrete cause of the -4 result I know of. I suggest you try changing the MQTT_VERSION value in PubSubClient.h - if I'm right about this being a version mismatch issue, that'll get things working.

It is still worth trying to get the newer version of mosquitto on there; lots of good bug fixes etc.

from pubsubclient.

noemark1 avatar noemark1 commented on May 24, 2024

And you are right sir - I just upgraded to version 1.4.3 and everything connects fine. Thank you for your help. Now to get all of my wireless nodes working...

Many thanks,

-Mark

from pubsubclient.

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.