Downlink from HTTP integration does not show in TTN Console and does not reach my device

I have an application with a device.
When I send a downlink to my device it doesn’t appear in my console.
What can be the issue?

I use the commandline to issue the postrequest:

curl -X POST --data '{"device_id":"my_device", "payload_raw":"AQE="}' https://integrations.thethingsnetwork.org/ttn-eu/api/v2/down/my_device/my_integration?key=ttn-account-my_key

does anyone have a clue?
thanks Theo.

Does TTN receive the uplink messages from the device? If so, is the rssi near the limit (~-140dB)?

If ttn does not recieve the uplink messages at all, no downlinks can be scheduled.

If the signal from your device to the gateway is too weak, maybe the device is not within range to receive downlinks.

1 Like

Thanks for the reply.
Yes, TTN receives uplink messages from the device.
And when I send downlink messages to the device via the TTN console, they show up in the console device data (first scheduled, then after an uplink message from the device actually sent) and they reach the device (it causes a led to be turned on).
But the message send via http (the command line message mentioned above) do not even show up in the the TTN console.

1 Like

Is that using the exact same URL you get as "downlink_url" in the JSON for uplinks? What response do you get from that curl command?

Also, the documentation uses "dev_id", not "device_id", and specifies "port" and "confirmed".

1 Like

Thanks arjanvanb, that was the solution, I had a typo: the documentation uses “dev_id”, not “device_id”.

1 Like

Did the curl command not give you some error from the server then?

No, there was no reply from the server.

That’s impossible; the server will always return some HTTP headers even if it returns no content. But apparently curl did not print anything. For command line testing, better include -i to see the response headers: curl -i -X POST --data .... Or -v for even more verbose output: curl -v -X POST --data ...

I just tested the curl with -i as advised and I got :

HTTP/1.1 404 Not Found
Server: nginx/1.13.7
Date: Thu, 01 Feb 2018 18:48:04 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 0
Connection: keep-alive

here is my curl command (I just modified my ttn account key)

curl -i -X POST --data '{"dev_id":"kukaoo-001","port":1,"confirmed":false,"payload_raw":"T0ZG"}' https://integrations.thethingsnetwork.org/ttn-eu/api/v2/down/my-app-id/my-process-id?key=ttn-account-v2.xxxxxxxxxxxxxxxxxxxxxxx

Help is much appreciated

I assume you replaced those too?

(I am not using the integration, so have not checked right now if an URL like this would work for me. I’d assume that an unknown my-app-id or my-process-id might yield a 404 Not Found as well.)

Hi Arjan, thanks for your reply. Sorry my mistake
I changed my-app-id and my-process_id to the right values and my error is now
there is something wrong I can’t see

HTTP/1.1 400 Bad Request
Server: nginx/1.13.7
Date: Thu, 01 Feb 2018 22:48:39 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 0
Connection: keep-alive

Hi Arjan,

Any chance you have an idea on my issue?

device : kukaoo
application : loratrack
http integration: wialongw

C:\Users\xxxx>curl -i -X POST --data '{"dev_id":"kukaoo","payload_raw":"AQE="}' https://integrations.thethingsnetwork.org/ttn-eu/api/v2/down/loratrack/wialongw?key=ttn-account-v2.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

HTTP/1.1 400 Bad Request
Server: nginx/1.13.7
Date: Mon, 05 Feb 2018 21:42:55 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 0
Connection: keep-alive

When using curl on Windows, you might want to have a look at Using curl or Postman for the HTTP Integration on Windows.

Thanks Arjan
problem solved.
Regards

JP

Hi, Arjan, Thanks for your hints and the advise regarding CURL on windows.

I am still running into similar problems when trying out Downlink:

curl -v -X POST --data "{\"dev_id\":\"XXXXREPLACED\",\"payload_raw\":\"AQE=\"}" https://integrations.thethingsnetwork.org/ttn-eu/api/v2/down/lXXXXREPLACED/XXXREPLACED?key=ttn-account-v2.SECRETKEY

I always get a HTTP Error Code 401 unauthorized as a response:

   Trying 13.69.184.129...
 TCP_NODELAY set
 Connected to integrations.thethingsnetwork.org (13.69.184.129) port 443 (#0)
 schannel: SSL/TLS connection with integrations.thethingsnetwork.org port 443 (step 1/3)
 schannel: checking server certificate revocation
 schannel: sending initial handshake data: sending 198 bytes...
 schannel: sent initial handshake data: sent 198 bytes
 schannel: SSL/TLS connection with integrations.thethingsnetwork.org port 443 (step 2/3)
 schannel: failed to receive handshake, need more data
 schannel: SSL/TLS connection with integrations.thethingsnetwork.org port 443 (step 2/3)
 schannel: encrypted data got 3013
 schannel: encrypted data buffer: offset 3013 length 4096
 schannel: sending next handshake data: sending 126 bytes...
 schannel: SSL/TLS connection with integrations.thethingsnetwork.org port 443 (step 2/3)
 schannel: encrypted data got 274
 schannel: encrypted data buffer: offset 274 length 4096
 schannel: SSL/TLS handshake complete
 schannel: SSL/TLS connection with integrations.thethingsnetwork.org port 443 (step 3/3)
 schannel: stored credential handle in session cache
 POST /ttn-eu/api/v2/down/secretID/SecretID?key=ttn-account-v2.hereIsMySecretkey HTTP/1.1
 Host: integrations.thethingsnetwork.org
 User-Agent: curl/7.55.1
 Accept: */*
 Content-Length: 41
 Content-Type: application/x-www-form-urlencoded

 upload completely sent off: 41 out of 41 bytes
 schannel: client wants to read 102400 bytes
 schannel: encdata_buffer resized 103424
 schannel: encrypted data buffer: offset 0 length 103424
 schannel: encrypted data got 201
 schannel: encrypted data buffer: offset 201 length 103424
 schannel: decrypted data length: 172
 schannel: decrypted data added: 172
 schannel: decrypted data cached: offset 172 length 102400
 schannel: encrypted data buffer: offset 0 length 103424
 schannel: decrypted data buffer: offset 172 length 102400
 schannel: schannel_recv cleanup
 schannel: decrypted data returned 172
 schannel: decrypted data buffer: offset 0 length 102400
 HTTP/1.1 401 Unauthorized
 Server: nginx/1.13.7
 Date: Sun, 29 Mar 2020 08:58:15 GMT
 Content-Type: text/plain; charset=utf-8
 Content-Length: 0
 Connection: keep-alive

 Connection #0 to host integrations.thethingsnetwork.org left intact 

Interesting: If I do the same thing on Google Script with my Request:

UrlFetchApp.fetch("https://integrations.thethingsnetwork.org/ttn-eu/api/v2/down/XXX/XXX?key=ttn-account-v2.SECRETKEYREPLACED/", options);

which looks like this:
UrlFetchApp.fetch([https://integrations.thethingsnetwork.org/ttn-eu/api/v2/down/XXX/XXXXr?key=ttn-account-v2.XXXREPLACED/, {method=POST, port=1.0, payload_raw=test, contentType=application/json, confirmed=false, dev_id=0123456}])

I get as an Answer:
HTTP Error Code 401

Anybody an Idea what I am doing wrong?
Anybody an idea what i need to set in TTN Console settings?

You’ll have to check id’s and secrets, both in the URL and in the JSON message.

I’m not sure if the decimal point in 1.0 is accepted. But surely "test" is not a valid Base64 encoded string. Also, it seems all these are attributes of options? Indeed, method and contentType should be attributes of options, but whatever is to be actually POSTed should be in something like options.body instead, like dev_id, payload_raw, port and confirmed. You’ll have to show some code rather than only the logs.

Also, I noticed your edit. I doubt that the slash you added after ?key=ttn-account-v2.XXXREPLACED/ is really in the log…

Ah, you’re also not setting Content-Type in your curl command.

Maybe the Content-Type should even be in something like options.headers. You’ll need to check Google’s documentation.

Hey Arjan,

thanks for that really fast answer. Your Content-Type hint finally solved my issue.
To help others running into the same mistake: Here is my Source Code for Google Script

function myResponse() {

  var data = {
    "dev_id": "0123456",
    "port": 1,
    "confirmed": false,
    "payload_raw" : "1QIDBA=="
  };

  var options =
   {
     'method' : 'post',
     'contentType': 'application/json',
     'payload': JSON.stringify(data)
   };
  
  var response = UrlFetchApp.fetch("https://integrations.thethingsnetwork.org/ttn-eu/api/v2/down/XXXXREPLACEME/XXXXREPLACEME?key=ttn-account-v2.XXXXREPLACEME", options);  
  
  //var response = UrlFetchApp.fetch('http://www.google.com/');
  Logger.log(response.getContentText()); 
  var Test = "0"  
}

more Info can be found here: DevDocumentationGoogle about Post in oogle Script

1 Like