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

Help with error message on net.HTTPClient() call to Raspberry PI php script


Question

Posted

Hi forum users

When the below function on HC2 scene is executed, I get the error 'Operation canceled'.

The scene is executing a php script running on a RPI webserver. That php script is executing another bash script taking snapshots from IP camera and store on a samba share.
Both the php and bash script are running fine without errors if I run them directly on the RPI.
Also the scene is running fine and executing the commands correctly on the RPI but I'm wondering where the error is coming from. It's not a good practise to keep it like that :-)
Since the scripts on the RPI are running without errors, I assume the mistake is in the lua. 
Anybody that can help me?

 

function triggerCamera()
  local selfhttp = net.HTTPClient()
selfhttp:request(url, {
  options={
    headers = selfhttp.controlHeaders,
    method = 'GET',
    timeout = 5000 -- was 5000
  },
  success = function(status)
    info("orange","STATUS: "..status.status)
    log("orange", "DATA: "..status.data)
  end,
  error = function(err)
    info("orange","ERROR: "..err)
  end
})
end -- function

4 answers to this question

Recommended Posts

  • 0
Posted

Don't know if it's the same case, but I have notice that when using variable by name "url" the things go weird.

Could you please change the "url" to other name like "selfUrl".

 

  • 0
  • Inquirer
  • Posted

    Hi @cag014,

    I tried your proposal, which was indeed not that bad, but it's not working. 
    Anybody have other idea's?

    • 0
    Posted (edited)

    Looking at your code I have few questions:

    1. Could you please post what exactly variable "url" is. It should include IP address and link...

    For example:

    local selfhttp = net.HTTPClient()

    selfhttp:request("http://127.0.0.1:11111/api/globalVariables",{ ....

    Make sure that your url include this data.

    2.  You are using commands info and log, I believe they are functions which are part of the scene code right?

    3. Could you post the entire code of scene? That should help a lot to find the error...

    Edited by cag014
    • 0
  • Inquirer
  • Posted

    Hi @cag014 & all
    I appreciate your help. But finally I've found the issue.
    By changing the timeout from 5000 to 15000 the error disappeared.
    In the backend, the script is looping in order to take several snapshot of the camera. This takes more than 5 seconds.

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