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

I have an issue trying to make and HTTPS POST request.

 

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.

 

Help!

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

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