2

I am using following code with HTTP module of the NodeMCU firmware. As per the documentation both HTTP and HTTPS URLs should work.

https://nodemcu.readthedocs.io/en/master/en/modules/http/#httppost

Though I am getting error when I use 'https'. 'http' is working fine for me. For URL in code, I am facing following error.

"The plain http request was sent for HTTPS port".

Please help.

http.post('https://maker.ifttt.com/trigger/......',
        'Content-Type: application/json\r\n',
        '{"value1":"mainlobby"}', function(code, data)
        if (code < 0) then
            print("HTTP request failed")
        else
        print(code, data)
        end        
  end
Marcel Stör
  • 22,695
  • 19
  • 92
  • 198
MarsTelnet
  • 471
  • 7
  • 18

2 Answers2

1

I suspect that your firmware does not have SSL/TLS enabled. So, it would internally use http instead of https but still send it to port 443.

Marcel Stör
  • 22,695
  • 19
  • 92
  • 198
  • Thanks. I missed to add SSL support in firmware. Though it seems like, in nodemcu 2.0.0 build, even after adding ssl support, it is not working. Though I get the answer to my query. Thanks again. http://stackoverflow.com/questions/42414431/nodemcu-lua-http-get-disconnected-with-error-8-what-is-error-8 – MarsTelnet Mar 06 '17 at 14:15
0

You're code seems fine, as you're saying the documentation supports http and https in the requests. What you're experiencing is likely an issue with the server not allowing http requests because it runs https protocol.

If you google your error you'll see that the error that is thrown an nginx 400 error.

Fredrik Schön
  • 4,888
  • 1
  • 21
  • 32
  • "an issue with the server not allowing http requests" - the OP is _not_ sending HTTP, at least not intentionally, with that example as the URL is `https://maker..`. He/she even says that using plain HTTP works. – Marcel Stör Feb 28 '17 at 16:27