Help with: error: expected primary-expression before ',' token

void loop() {
  if (!client.connected()) {
    long startConnect = millis();
    if ((startConnect - lastReconnect) > 1000) {
      lastReconnect = startConnect;
      if (client.connect(net_hostname, mqtt_user, mqtt_pass)) {
        Serial.println("MQTT connected");
        if (client.subscribe(mqtt_topic)) {
          Serial.printf("Subscribed to topic % s\n", mqtt_topic);
        } else {
          Serial.printf("Failed to subscribe to topic % s\n", mqtt_topic);
        }
      } else {
        Serial.println("MQTT connect failed, retrying");
      }
      if (client.connected()) {
        lastReconnect = 0;
      }
    }
  }

  client.loop();
}

I am getting the following error when trying to compile the above code.

esp-mqtt-serial:59:49: error: expected primary-expression before ',' token

  • if (client.connect(net_hostname, mqtt_user, mqtt_pass)) {*

Any suggestions?

^

lukehancock83:
Any suggestions?

Just the usual one: post the whole thing.