Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not compile on ESP8266 when calling connect() with port #106

Open
ferdinand0815 opened this issue Jun 18, 2024 · 3 comments
Open

Does not compile on ESP8266 when calling connect() with port #106

ferdinand0815 opened this issue Jun 18, 2024 · 3 comments
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@ferdinand0815
Copy link

The library fails to compile on ESP8266 when calling connect() with a port, as in mqttClient.connect(mqttBrokerIp, mqttPort).

error: call of overloaded 'connect(IPAddress&, uint16_t&)' is ambiguous

ArduinoMqttClient/src/MqttClient.h:82:15: note: candidate: 'virtual int MqttClient::connect(IPAddress, uint16_t)'
   82 |   virtual int connect(IPAddress ip, uint16_t port = 1883);
      |               ^~~~~~~
/home/ffelder/Arduino/libraries/ArduinoMqttClient/src/MqttClient.h:85:15: note: candidate: 'virtual int MqttClient::connect(const IPAddress&, uint16_t)'
   85 |   virtual int connect(const IPAddress& ip, uint16_t port) { return 0; }; /* ESP8266 core defines this pure virtual in Client.h */
      |               ^~~~~~~

This has actually already been fixed quite some time ago in this pull request #33 by removing the ESP8266 specific code in MqttClient.h. I briefly tested the connect() using test.mosquitto.org, no idea about flush and stop.

@pennam
Copy link
Contributor

pennam commented Jun 18, 2024

which library version and core version are you using?

@ferdinand0815
Copy link
Author

ferdinand0815 commented Jun 18, 2024

ArduinoMqttClient version=0.1.8
ESP8266 is 3.1.2

The VS Code Arduino extension seems to use CLI 0.31

@ferdinand0815
Copy link
Author

This is only an issue when connecting to a host using its IPAddress, not via host name.

This offers a quick solution, convert the IP to a string .. not ideal but whatever.

uint16_t mqttPort = 1883;
IPAddress testIP = IPAddress(91, 121, 93, 94); // test.mosquitto.org

// works
mqttClient.connect(testIP.toString().c_str(), mqttPort);

// does not compile
mqttClient.connect(testIP, mqttPort);

@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

3 participants