Copyright ©

Mongoose OS Forum

ATTENTION! This forum has moved to:

Do not post any new messages.

How to send requests to JSON-RPC with curl?

kiotekiote Estonia
edited March 2019 in Mongoose OS

Hi! I'm using latest mongoos os + ESP 32 for simple sensors' reading.
Would like to expose this data to other services in local network and JSON-RPC seems to be a good way to do that.
Have to say I have no previous experience with embedded programming but have some in general API-programming (both using and making).

so I've added a simple function to my main.js:

RPC.addHandler('TempHumid.Read', function(args) {
  return { temp: dht.getTemp(), humid: dht.getHumidity() };

and I know the device's IP address.

but when I'm trying to curl there, for example like that:

➜  ~ curl -o -
curl: (7) Failed to connect to port 80: Connection refused
➜  ~ curl -d '{}' -o -
curl: (7) Failed to connect to port 80: Connection refused

I'm getting "Connection refused" errors, looks like I'm doing something wrong, or something is missing

Can someone advice, please?


  • nliviunliviu Romania

    main.js or init.js?
    RPC - Remote Procedure Calls

    Is TempHumid.Read listed by mos call RPC.List?

  • kiotekiote Estonia
    $ mos call RPC.list

    and it's init.js, instead of main.js I have main.c

  • kiotekiote Estonia

    ah! so I ended up adding these two lines to mos.yml:

      - origin:
      - origin:

    and now it's working as expected. Well, I was simply lacking http server :smiley:

Sign In or Register to comment.