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

Is net.HTTPClient() different in a scene or in a quiclkapp ?


Question

Posted
Hi,
 
 
I noticed a different behavior between scenes and Qapps with net.HTTPClient().

This code works fine in my scene, but not in my Qapp. I have a 404 error, as if my passwords were wrong.
 
Is net.HTTPClient() different in a scene or in a quiclkapp ?
 

 

This is my QA code that does not work (404 error) : 

 

Please login or register to see this code.

 

Qapp debug  :

Please login or register to see this code.

 

This is my scene code that is working very well (302 code)

Please login or register to see this code.

 

scene debug:

Please login or register to see this code.

6 answers to this question

Recommended Posts

  • 0
Posted

No, I think they should be the same. The json encode/decoder is different and behaves differently, but that's not your problem here... mostly issues with empty arrays...

The status 302 is a redirect that is tricky, but I don't think they should give a 404 back instead...

Another thought, the url in the QA is 

Please login or register to see this code.

 

and in the Scene

Please login or register to see this code.

The difference being the trailing slash - sometimes the server API can be picky about stuff like that.

  • 0
  • Inquirer
  • Posted (edited)

    Hi jgab,

     

    Thanks for your answer.

     

    The code 302 tells us that the syntax is ok.

    The web server tell me to go on the special logged URL (when the credentials are correct) and to "/login/" (when credentials are wrong).

    That is ok in a scene.

     

    But I always have code 404 with a qapp. :(

     

    I have created the same function to test my scene and my qapp.

    It is exactly the same funtion.

    I don't understand why the return status is not the same.

     

    Can you test on your HC3 ?

     

    QAPP :

    Please login or register to see this code.

     

    QAPP DEBUG :

    Please login or register to see this code.

     

     

     

    SCENE :

    Please login or register to see this code.

     

    SCENE DEBUG

    Please login or register to see this code.

     

    Edited by stipower
    • 0
    Posted

    Yes, they do behave differently. Could it be that the QA implementation, to be "helpful", returns a 404 instead of a 302 because it won't do a redirect automatically?
    The headers seems to be more or less the same with cookies and endpoints even if it returns a 404...

    Alternatively, do an implementation with net.TCPClient and send a raw HTTP request and parse the raw result.

    • 0
  • Inquirer
  • Posted

    Hi,

     

    I can try this.

    But I have never implemented net.TCPClient.

    Can you help me quickly to convet my lua code ?

    • 0
    Posted

    Well, I just noticed that it's https, which makes it (too) complicated.

    Fibaro has already all the components (luasocket and luasec) so it should be easy for them to support SSL sockets if they wanted.

    • 0
  • Inquirer
  • Posted (edited)

    Well, I am not sure to understand.

    What should I try right now to fix it ?

    Edited by stipower

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