Hey Community,
i want to initiate downlinks with my Blynk app.
I set up an Application in TTN with an HTTP Integration. Data forwarding from TTN to Blynk works fine. Now i want to go the reverse way. Putting the Downlink-Link in Postman (POST method and data in JSON format in the body) gives me proper downlink initiations (i know, only 10 per day). But doing the same in Blynk results in no action in the TTN console. For testing i made both (postman and blynk) send data to requestbin, to see what traffic and data actually is arriving:
Postman (successful downlinks):
Blynk (not showing up in the ttn console at all):
any ideas why this is not working? Changing the content-type in blynk doesnât help either. Requestbin says in the latter case: content-type text/plain; charset=UTF-8
Did you also add some ?key=ttn-account-v2.dummy-secret part to the URL of requestbin.com? Maybe Blynk is doing some funny encoding of the question mark, or of the parameter value.
I donât know Blynk, but how did you set it up? Can you test without a User-Agent header in Postman?
So you set it to text/plain and Blynk changes that into text/plain; charset=UTF-8?
I wonder if Blynk always does that, or if it sees some funny characters that are not plain ASCII, and adds that encoding instruction. Does copying the JSON content into some editor show any funny characters, or differences in line endings? Maybe copy the JSON from Blynk into Postman and POST that? By the way: application/json should be fine of course. Unless that JSON indeed includes some funny characters, like non-breaking whitespace.
i canât do that. modifying the url. in. requestbin is not possible. but doing something like this: https://en9iip5qks.x.pipedream.net?
ended up in â âŚ/?
i think blynk alters the url in some way.
no, this remains unchanged
so i tried so send an http post request with the esp8266wifi library. the problem there is that my esp8266 doesnât support https and the ttn-http-integration doesnât support http. correct?
Iâve never tried, but it makes sense, this being 2020. But if the ESP8266 WiFi library does not support it, then the following should surely use an http:// URL, not https://:
Donât forget to test without a User-Agent in Postman!
Some testing shows TTN doesnât care about a missing User-Agent. The following (along with disabling some headers in Postmanâs preferences) creates the same headers as shown in your RequestBin tests, and works just fine in TTN:
Also, it seems that RequestBin shows UTF-8 encoded non-breaking whitespace, which would also increase the Content-Length which does not happen for your tests:
So, to ensure Blynk supports Letâs Encrypt (which I really expect it willâŚ), you might want to test with https://beeceptor.com, which uses Letâs Encrypt just like TTN. (RequestBin uses an Amazon AWS server certificate. Both Beeceptor and RequestBin use a wildcard, while TTN does not.)
Thank you for your help, I really appreciate it. So I did the Test. Postman-Requests are being displayed in Beeceptor but Blynk-Requests sadly arenât
Iâm running a local Blynk Server. Using the ânormalâ Blynk server worked out well.
So, now I will read on how to put Letâs Encrypt on my Rapsberry and post the solution here once I get there.
Any recommendations for readings/tutorials?
Good job, @arjanvanb !
Ah, then Iâd also try to find the local serverâs logs, which might show clues for future problems?
It seems this server is a Java application? Then youâll need to make Java trust the Letâs Encrypt Certificate Authority chain. (For this problem, you do not need to make your own instance provide HTTPS, but your instance needs to accept TTNâs server certificate.) Upgrading your Java runtime might already do the trick:
Itâs working!!! Updating to the latest build of Java 8 didnât help (newer versions are not supported by the Blynk server. Eventually also Version 11, but not on the RaspPi).
Had to install and activate Letâs Encrypt Certificates and taking my RaspPi to 2020, time of SSL
Another issue in that context: Blynk application needs one of the following answers from TTN HTTP Integration: 200 or 302.
What I get after successful data forwarding: 202.
Is there a way of changing the TTN-Serverâs answer to 200?
Not without an intermediate server. However, Iâd say that is a bug in Blynk, which you might want to report there. Any HTTP 2xx code should really be handled as success, and that should be easy to fix.
@arjanvanb
I addressed the problem to Blynk-Community and one of the founders integrated 202 to the list of accepted HTTP answers just two hours later (very fast ). Now everything is working as expected and I successfully set up data-exchange (through ABP) between Blynk and TTN.
Your help was the biggest contributing factor. Once again thank you!!!