Socket error: [Errno 111] Connection refused


#1

Hi, I have a problem when I send a message from my app (in nodejs). I send the message via “hologram-node” module or “request”. My problem is that in the Hologram console the data message say “Socket error: [Errno 111] Connection refused” and the data sent is “Test Message from App”.

Here is my methods:

// Message from hologram-node module
function sendMessage() {
    var HologramAPI = Hologram("my_api_ke", { orgid: "my_orgid" });
    HologramAPI.Device.sendData(["174220"], "Test Message from App", "80", "TCP").then((resp) => {
        console.log("Response");
        console.log(resp);
    });
}

// Message from request module
function sendMessagerequest() {
     var request = require('request');
    
     request({
         method: 'POST',
         url: 'https://dashboard.hologram.io/api/1/devices/messages?apikey=my_api_key',
         headers: {
             'Content-Type': 'application/json'
         },
         body: "{  \"deviceids\": [174220],  \"protocol\": \"TCP\",  \"port\": 80,  \"encrypted\": false,  \"data\": \"Test Message from App\"}"
     }, function (error, response, body) {
         console.log('Status:', response.statusCode);
         console.log('Headers:', JSON.stringify(response.headers));
         console.log('Response:', body);
     });
}

I need that the message in console says “Test Message from App”.
Someone can help my? Thanks