Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

net.HTTPClient() call gives "short read" Error


Sergey Malygin

Question

Hi all,

 

I have an issue trying to make and HTTPS POST request from my LUA scnene in Fibaro HC.

 

I am getting "short read" error with the URL "https://api2.magicair.tion.ru/idsrv/oauth2/token"

 

This is my scene:

 

=============================================

--[[
%% properties
%% events
%% globals
--]]

local authData = "username=XXX&password=YYY"

function doTest()
      print('Test!')
    local requestUrl = "https://api2.magicair.tion.ru/idsrv/oauth2/token"
    local httpClient = net.HTTPClient()
    httpClient:request(requestUrl, { 
        options = {
            method = "POST",        
          headers = {
            ["Content-Type"] = "application/x-www-form-urlencoded",
            ["Content-Length"] = tostring(authData:len())
            },
          data = authData,
          timeout = 5000
        },
           success = function (response) fibaro:debug (response.data) end,
           error  =  function (err) fibaro:debug ("Error: "  .. err) end
      })
  
  setTimeout(doTest, 5*1000)

end

print('Script start...')
doTest()

=============================================

 

I am getting the following in my log:

 

[DEBUG] 15:16:52: Script start...
[DEBUG] 15:16:52: Test!
[DEBUG] 15:16:52: Error: short read

 

I have been trying to play with headers, data format, timeouts and all parameters I could find, however I always get the same error with the provided URL.

Other HTTPS URLS I tried with GET method works just fine.

 

Also I have been trying to do the same with cURL and it works fine with the exact same set of headers and payload (with full credentials string, of course).

 

So the issue is somehow connected with this specific URL: "https://api2.magicair.tion.ru/idsrv/oauth2/token"

 

The Internet is saying that short read problem in HTTPClient request might be related to ciphering protocols mismatch between the client and server.

So there could be some parameter regulating this?


2 main versions, which I see:

1. Some tricky param is required to form the correct HTTPS request.

2. Some bug / missing feature in HTTPClient implementation in HC2.

 

Anyway I am stuck and need the help from the community and HC developers.

 

 

Has anyone seen something similar? Any clues?

 

Please help!

 

Many thanks in advance.

 

PS Using the latest FW 4.51 of Fibaro Come Center 2

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

hi Sergiy!

 

according to official answering from Fibaro support: HC2: doesn't work properly with HTTPS.

for example, I know at least 3 / reading / failing on HTTP code / TLS issue / (including your) issues with HTTPS.

 

and for example, this issue what I reported years ago still opened. 
 

Please login or register to see this code.

 

Edited by 10der
Link to comment
Share on other sites

  • 0
  • Inquirer
  • Thanks @10der!

     

    This is what I was affraid to hear...

     

    However it is quite strange to have such a bug in a modern system.

    It looks like some low level library providing TLS support is just too old...

     

    In other home automation solutions it works with no issues!

     

    I will try to contact Fibaro support on this as well.

     

    By the way did you try to make it working on lower level?

    I've seen some TCP send commands available in Fibaro Lua?

     

    Do you think it might work if implememented correctly?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • On 9/9/2018 at 7:31 PM, 10der said:
    On 9/9/2018 at 7:19 PM, Sergey Malygin said:

    I will try to contact Fibaro support on this as well.

    Good luck ;)

     

    Finally the issue has been fixed in HC2 4.520 FW!

     

    My code works fine now.

     

    Thanks and good luck.

    • Like 1
    Link to comment
    Share on other sites

    • 0

    How did this pan out?? I want to try and call a HTTPS statement from a scene or VD when a movement sensor is breached.. but can’t get it to work.. any help would be appreciated.. what does the code look like?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • On 12/4/2018 at 10:06 AM, rajp said:

    How did this pan out?? I want to try and call a HTTPS statement from a scene or VD when a movement sensor is breached.. but can’t get it to work.. any help would be appreciated.. what does the code look like?

     

    Hi Raj,

     

    What exactly is not working in your case?

     

    My code example was in the first message in this thread.

     

    Initially my code abended with "short read error" in the log, but after upgrading to 4.520 FW started to work OK.

     

    Best regards,

    Sergey

    Link to comment
    Share on other sites

    • 0
    On 1/20/2019 at 8:52 AM, Sergey Malygin said:

     

    Hi Raj,

     

    What exactly is not working in your case?

     

    My code example was in the first message in this thread.

     

    Initially my code abended with "short read error" in the log, but after upgrading to 4.520 FW started to work OK.

     

    Best regards,

    Sergey

    Hi Sergey.. after lot of digging around and referencing the web, I found that my call structure was not correct.. got someone else from work to help me out on this and this fixed it.. it works beautifully now..

     

    My Fibaro PIR sensor, when breached runs a scene which sends a HTTPS call to Macrodroid app on my Samsung tablet and this in turn switches the screen brightness to 100% so that I can see what is going on with the CCTV cameras.. this then drops down to 25% brightness after 5 mins.. works brilliantly considering that it is going thru multiple hops...

    Link to comment
    Share on other sites

    • -2
    8 minutes ago, Sergey Malygin said:

    I will try to contact Fibaro support on this as well.

    Good luck ;)

     

    8 minutes ago, Sergey Malygin said:

    By the way did you try to make it working on lower level?

    are you asking me do implement SSL protocol via tcp/ip stack on pure LUA?

    a ha ha are you kidding me?! :D

    Please login or register to see this spoiler.

     

    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...