Imroy / pubsubclient

A client library for the ESP8266 that provides support for MQTT
MIT License
433 stars 115 forks source link

Can't connect.. #53

Closed larsenglund closed 8 years ago

larsenglund commented 8 years ago

I can't get it to connect. I can connect just fine from a PC. I create my objects like this:

WiFiClient wclient;
PubSubClient mqttClient(wclient);

then set the server ip and port like this mqttClient.set_server(mqttIp, mqttPort); then in loop i do this:

  if (!mqttClient.connected()) {
    Serial.println("Not connected..");
    if (mqttClient.connect("test")) {
      mqttClient.set_callback(mqttCallback);
      mqttClient.subscribe("inTopic");
      mqttClient.publish("outTopic", "Hello!");
    }
  }

  if (mqttClient.connected()) {
    mqttClient.loop();
  }

But it just prints Not connected.. once every 15s which I guess is the timeout... Am I overlooking somthing?

larsenglund commented 8 years ago

Wrong mosquitto version was the problem, I just assumed I would get the latest version by simply apt-getting but that gave v0.15, assumptions are bad for you >_<