Problems connecting to port 8883 with arduino

293 views
Skip to first unread message

Dan Hoover

unread,
Jul 24, 2017, 10:56:28 PM7/24/17
to MQTT
I'm hoping this is something simple that I'm just not understanding.  I'm trying to wrap my mind around both ethernet and mqtt on arduino.  I've used them separately, but I can get a lot of raspberry pi's out of the way if I can publish mqtt messages directly from the arduino. 

I have a nano with the nano arduino shield.  I can publish messages to my local network (192.168.0.222) with no password on port 1883.

I can publish messages to my private server which is on the public internet from a raspberry pi (so I definitely know the password, ip addresses etc).  

However, I can't figure out how to publish messages from the arduino when I need a username and password.  Here's my local sketch...

#include <UIPEthernet.h>
#include "PubSubClient.h"


#define CLIENT_ID       "BoilerRoom"


#define INTERVAL        15000 // 15 sec delay between publishing
uint8_t mac
[6] = {0x00,0x01,0x02,0x03,0x04,0x05};

EthernetClient ethClient;
PubSubClient mqttClient;

long previousMillis;

void setup() {

 
// setup serial communication
 
Serial.begin(9600);
 
// setup ethernet communication using DHCP
 
if(Ethernet.begin(mac) == 0) {
   
Serial.println(F("Ethernet configuration using DHCP failed"));
   
for(;;);
 
}
 
// setup mqtt client
  mqttClient
.setClient(ethClient);
  mqttClient
.setServer("192.168.0.222",1883);
 
Serial.println(F("MQTT client configured"));

  previousMillis
= millis();
}

void loop() {
 
// check interval
 
if(millis() - previousMillis > INTERVAL) {
    sendData
();
    previousMillis
= millis();
 
}
  mqttClient
.loop();
}

void sendData() {
 
char msgBuffer[20];

 
if(mqttClient.connect(CLIENT_ID)) {
   mqttClient
.publish("boilerTemp", "5000");
   
Serial.println(F("Attempted to send temp"));
   

 
}else{
     
Serial.println(F("Failed"));
 
}
}



Looking at the documentation, I was assuming I could change port 1883 to 8883 and change this line...

 
 if(mqttClient.connect(CLIENT_ID)) {


to

  if(mqttClient.connect(CLIENT_ID, "myUsername", "myPassword")) {



but that doesn't seem to be working.  Can anyone help?

Nicholas Humfrey

unread,
Jul 25, 2017, 3:42:32 AM7/25/17
to mq...@googlegroups.com
Hello Dan,

Port 8883 is for secure communication using TLS.
Unfortunately an Arduino Nano does not have the resources to be capable of TLS.


--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.

Paul Fremantle

unread,
Jul 25, 2017, 6:50:50 AM7/25/17
to mq...@googlegroups.com
Just to add to Nicholas's post:

Normally, you would not use a username/password without TLS, because someone on a local network could probably sniff it out. Hence the examples show the use of MQTT/TLS for uid/pw. 

The ESP8266 is a small, cheap wifi device that supports TLS, but if you are sticking with an Arduino Nano then you can either choose to send uid/pw over MQTT (without encryption) or simply go ahead without uid/pw.

Paul

To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+unsubscribe@googlegroups.com.

To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.

--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+unsubscribe@googlegroups.com.

To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.



--
Paul Fremantle
Doctoral Researcher, University of Portsmouth, School of Computing
Visiting Scientist, Institute of the Architecture of Application Systems, Stuttgart
Visiting Lecturer, Software Engineering Programme, Oxford University
Co-Founder, WSO2
Apache Member and Committer
twitter: pzfreo / skype: paulfremantle / blog: http://pzf.fremantle.org

Dan Hoover

unread,
Jul 25, 2017, 8:43:25 AM7/25/17
to MQTT
Thanks for the feedback everyone! I have some esp8266 boards and some esp32, the problem is that I think I'm really going to need a wired connection. I don't think wireless is going to cut it.  Originally I was piping the sensor data from a mega to a pi and doing my mqtt on the pi, but that won't scale very well.  It required basically one pi per arduino. 

My current method involves sending all my unencrypted sensor data/mqtt calls from all over my campus to my server closet where it's all "repeated" and sent out using TLS. 

That works, but now my major security issue is guests sniffing the traffic. 

Is there any other option I'm missing?
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.

To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.

--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.

To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.

Paul Fremantle

unread,
Jul 25, 2017, 11:32:48 AM7/25/17
to mq...@googlegroups.com
Dan

I don't know how well supported this is, but there is this:


Paul

To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+unsubscribe@googlegroups.com.

To post to this group, send email to mq...@googlegroups.com.
Visit this group at https://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.

Paul Fremantle

unread,
Jul 25, 2017, 11:36:28 AM7/25/17
to mq...@googlegroups.com
Or this https://github.com/esp8266/Arduino/issues/962 which seems to indicate someone has added a W5100 ethernet chip and got it working with ESP8266 and Ethernet.h.

Paul

Dan Hoover

unread,
Jul 25, 2017, 11:38:14 AM7/25/17
to MQTT
That's some pretty cool hackery. Thanks for that. It's probably a little bit beyond what I can solder together x 100, but it's pretty cool. Thanks for your time on that.

Dan Hoover

unread,
Jul 25, 2017, 11:38:37 AM7/25/17
to MQTT
Has anyone used Paho for arduino?

Nicholas Humfrey

unread,
Jul 25, 2017, 6:35:33 PM7/25/17
to mq...@googlegroups.com, Dan Hoover
Hi Dan,

There is this Olimex ESP32 evaluation board with Ethernet:
https://www.olimex.com/Products/IoT/ESP32-EVB/open-source-hardware


nick.
>> https://stackoverflow.com/q/44310817/1156096 [1]
>> Visit this group at https://groups.google.com/group/mqtt [2].
>> For more options, visit https://groups.google.com/d/optout [3].
>>
>> --
>> To learn more about MQTT please visit http://mqtt.org
>> ---
>> You received this message because you are subscribed to the Google
>> Groups "MQTT" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to mqtt+uns...@googlegroups.com.
>> To post to this group, send email to mq...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/mqtt [2].
>> For more options, visit https://groups.google.com/d/optout [3].
>
> --
>
> Paul Fremantle
> Doctoral Researcher, University of Portsmouth, School of Computing
> Visiting Scientist, Institute of the Architecture of Application
> Systems, Stuttgart
> Visiting Lecturer, Software Engineering Programme, Oxford University
> Co-Founder, WSO2
> Apache Member and Committer
>
> email: paul.fr...@port.ac.uk, pa...@fremantle.org
> twitter: pzfreo / skype: paulfremantle / blog:
> http://pzf.fremantle.org
>
> --
> To learn more about MQTT please visit http://mqtt.org
> ---
> You received this message because you are subscribed to the Google
> Groups "MQTT" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to mqtt+uns...@googlegroups.com.
> To post to this group, send email to mq...@googlegroups.com.
> Visit this group at https://groups.google.com/group/mqtt.
> For more options, visit https://groups.google.com/d/optout.
>
>
> Links:
> ------
> [1] https://stackoverflow.com/q/44310817/1156096
> [2] https://groups.google.com/group/mqtt
> [3] https://groups.google.com/d/optout

Paul Fremantle

unread,
Jul 25, 2017, 7:19:05 PM7/25/17
to mq...@googlegroups.com
Thanks Nick


Looks useful.

Paul

--
To learn more about MQTT please visit http://mqtt.org
--- You received this message because you are subscribed to the Google Groups "MQTT" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+unsubscribe@googlegroups.com.

Dan Hoover

unread,
Jul 26, 2017, 4:17:53 PM7/26/17
to MQTT, mud...@gmail.com
That's out of stock, but that thing looks sweet. I'm going to look into it. Thanks!
Reply all
Reply to author
Forward
0 new messages