ESP8266: http-server Port Binding Error with AWS IoT

#1

Hi folks, I am trying to use an ESP8266 device to connect with AWS IoT. There seems to be a port binding error occurring in mgos_http_server.c. I was hoping someone could point me in the right direction to solve this.

  1. My goal is: ensure that port 80 is properly bound by http-server on boot when integrating with AWS IoT
  2. My actions are: I followed the instructions here: https://aws.amazon.com/blogs/apn/aws-iot-on-mongoose-os-part-1/ however, I am still getting errors regarding this port binding.
  3. The result I see is: [show the result - log, etc]
[Nov  1 01:35:11.384] mg_ssl_if_mbedtls.c:57  mbed TLS 2.13.1-cesanta5
[Nov  1 01:35:11.389] mgos_vfs_dev.c:73       sfl0: sysflash (), size 4194304
[Nov  1 01:35:11.395] mgos_vfs_dev.c:73       root: part ({"dev": "sfl0", "offset": 32768, "size": 524288}), size 524288
[Nov  1 01:35:11.404] mgos_vfs.c:147          /: SPIFFS @ root, opts
[Nov  1 01:35:11.539] mgos_vfs.c:319          /: size 474641, used: 119978, free: 354663
[Nov  1 01:35:11.556] mgos_sys_config.c:231   Loading conf0.json
[Nov  1 01:35:11.754] mgos_sys_config.c:231   Loading conf9.json
[Nov  1 01:35:11.762] mgos_sys_config.c:347   MAC: 807D3A7CD1DE
[Nov  1 01:35:11.767] mgos_sys_config.c:355   WDT: 30 seconds
[Nov  1 01:35:11.771] gpio_i2c_master.c:242   I2C GPIO init ok (SDA: 5, SCL: 4, freq: 100000)
[Nov  1 01:35:11.807] mgos_atca.c:266         ATECC508A @ 0/0x60: rev 0x5000 S/N 0x1234bff1a03a8b9ee, zone lock status: yes, yes; ECDH slots: 0x0c
[Nov  1 01:35:11.819] bcn 0
[Nov  1 01:35:11.819] del if1
[Nov  1 01:35:11.820] usl
[Nov  1 01:35:11.820] mode : null
[Nov  1 01:35:11.821] mgos_wifi.c:88          WiFi STA: Using config 0 (TestWifi)
[Nov  1 01:35:11.828] mgos_wifi.c:468         WiFi mode: STA
[Nov  1 01:35:11.831] esp_wifi.c:118          WiFi mode: STA
[Nov  1 01:35:11.835] mode : sta(80:7d:3a:7c:d1:de)
[Nov  1 01:35:11.837] add if0
[Nov  1 01:35:11.838] sleep disable
[Nov  1 01:35:11.839] WPA2 ENTERPRISE VERSION: [v2.0] disable
[Nov  1 01:35:11.843] mgos_wifi.c:274         WiFi STA: Connecting to TestWifi
[Nov  1 01:35:11.850] mgos_http_server.c:268  Error binding to ['80']
[Nov  1 01:35:11.854] mgos_deps_init.c:140    http-server init failed
[Nov  1 01:35:11.859] esp_main.c:184          MG init error: -32
[Nov  1 01:35:11.863] esp_main.c:198          Init failed: -32
  1. My expectation & question is: I expect the device to boot normally, bind to the appropriate port specified in the config, and connect to the wifi network.
#2

Well, I don’t know what your config says.
You don’t need port 80 to connect to AWS, perhaps you’d want it for some field config, but you don’t need it for AWS. The http server should default to the proper ports with just loading its library.
May I see your mos.yml and whatever you put in config9 ?

If you can read spanish, I have a tech note on connecting to AWS here. Or maybe you can just browse the code, here.

There’s also the official tutorial here

#3

As it turns out, this was my error. I was using python’s subprocess module to automate the steps outlined in the AWS tutorial linked above. For some reason, the setup commands were not actually executing properly when using the subprocess module to execute them. Setting shell=True in the subprocess made the steps work as expected. Placing the commands in a bash script also works.