Mongoose OS 2.17.0 seems to break RPC mechanism

#1

Hi!

I have a mongoose application written in C which relies on the RPC mechanism over REST my implementation works fine in 2.16.0 but after upgrading to 2.17.0 it stopped working completely

when I test my custom RPC call in 2.17.0 I get:
curl 192.168.4.1/rpc/getTimers
curl: (7) Failed to connect to 192.168.4.1 port 80: Connection refused

In 2.16.0 it works fine and I get a json response:
curl 192.168.4.1/rpc/getTimers
{
"timer_count": 0,
"timer_array": []
}

handler is setup like this for 3 custom handlers:
mg_rpc_add_handler(mgos_rpc_get_global(), "setTimers", "{}", rpc_set_timers_cb, NULL);
mg_rpc_add_handler(mgos_rpc_get_global(), "getTimers", "{}", rpc_get_timers_cb, NULL);
mg_rpc_add_handler(mgos_rpc_get_global(), "getDeviceTime", "{}", rpc_get_device_time_cb, NULL);
mos.yml file for 2.16 looks like this:

author: BMD
name: PureSmart
description: Smart Product
version: 3.0.0
manifest_version: 2018-09-24
libs_version: 2.16.0
modules_version: 2.16.0
mongoose_os_version: 2.16.0

tags:
  - c
sources:
  - src
config_schema:
  - ["dns_sd.enable", true]
  - ["dns_sd.host_name", "pure-smart"]
  - ["wifi.ap.ssid", "pure-smart-??????"]
  - ["wifi.ap.pass", ""]
  - ["provision.button.pin", 0]
  - ["provision.button.hold_ms", 3000]
  - ["i2c.enable", true]
  - ["i2c.sda_gpio", 4]
  - ["i2c.scl_gpio", 5]
  - ["dash.token", "NOT-SET"]
  - ["file_logger.enable", false]


filesystem:
  - fs
  - persistent_storage_timer.json

build_vars:
  ESP_IDF_SDKCONFIG_OPTS: "CONFIG_TCPIP_TASK_STACK_SIZE=8192" 

libs:
  - origin: https://github.com/mongoose-os-libs/ca-bundle
  - origin: https://github.com/mongoose-os-libs/core
  - origin: https://github.com/mongoose-os-libs/dash
  - origin: https://github.com/mongoose-os-libs/dns-sd
  - origin: https://github.com/mongoose-os-libs/provision
  - origin: https://github.com/mongoose-os-libs/rpc-common
  - origin: https://github.com/mongoose-os-libs/rpc-service-config
  - origin: https://github.com/mongoose-os-libs/rpc-service-fs
  - origin: https://github.com/mongoose-os-libs/rpc-service-ota
  - origin: https://github.com/mongoose-os-libs/rpc-service-wifi
  - origin: https://github.com/mongoose-os-libs/rpc-uart
  - origin: https://github.com/mongoose-os-libs/wifi
  - origin: https://github.com/mongoose-os-libs/pwm
  - origin: https://github.com/mongoose-os-libs/i2c
  - origin: https://github.com/mongoose-os-libs/cron
  - origin: https://github.com/mongoose-os-libs/sntp

Is this a known issue or has the RPC setup procedure changed in version 2.17.0? should I explicitly open port 80 in 2.17.0? For now it is fine for me to work with 2.16.0 but I find it strange that an update of the release branch breaks this feature. Any help is appreciated!

1 Like
#2

You need the http-server library. It used to be included by dns-sd, but not anymore

#3

Thank you for your quick reply! That solved it indeed, thanks!

Maybe it is a good idea to update the RPC User Guide so that it states you need http-server and rpc-common when using REST.