Unable to connect to cloud using client.connect function

Dear all,

I have been working on a project in which i send data from photon to bluemix cloud through an MQTT broker, specifically mosquitto.

I am using the MQTT library available on particle build.

there is a client.connect function which i typed in as,

client.connect(“messaging.quickstart.internetofthings.ibmcloud.com”,1883);

or client.connect(server,1883);

where the server is my IP address

Despite looking at several examples online and through forum posts, i am still unable to compile the code. The error i am getting is as follows;

mqtttest.cpp:37:77: error: no matching function for call to ‘MQTT::connect(const char [51], int)’

i do not understand where i am going wrong. I have gotten mosquitto to listen to port 1883 but there is nothing being transmitted to it.

Please do help me through this problem and i apologise if this sounds amateurish.

Thank you so much.

Usually with the error message you quoted you also get another one that suggests the nearest candidate function that could be found.
Could you have a look at that and/or post it as well - saves me to look into the lib :wink:


Did it anyhow :sunglasses:

   bool connect(char *);
   bool connect(char *, char *, char *);
   bool connect(char *, char *, uint8_t, uint8_t, char *);

These are the available overloads and there is no bool connect(char*, int).
Have a look at the libraey samples to see how to use them correctly.

Hello @ScruffR thank you for such a quick response and i apologise for such a late reply.

The link i got the code from is below.

this example does not use ibm cloud which is why i was modifying it to my project requirements. Do let me know if there is anything i am doing wrong.

Thank you and apologies for the late response once again.

If you modify the code, you still need to use the supplied functions and not non-existent ones, as I’ve written in my post above.

Another thing might be the multi-part URL you provide. There used to be issues with addresses having more that two dots. With version 0.4.7 you’re definetly allowed three dots, but I’m not sure beyond that.
But this should not stop you from building - that’s definetly due to the wrong use of connect().