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.
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.)
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!!!