Exec Binding, httpPost and curl don't reliably send data to Dashing dashboard

i’m posting data to my dashing dashboard using sendHttpPostRequest and json and can load graph data just fine and most things, but some items just don’t post all the time, can’t understand the intermittent behaviour.
i’ve also implemented a script (this is in ubuntu 15.04) to call the curl function and that works exactly the same way, sometimes the numbers show up, sometimes not.
BUT, when i call the script from the command line with the exact same syntax that OH does it works every time, near-instantly. so it seems like something gets screwed when leaving OH, either from the sendHttpPostRequest or calling a script using executecommandline

cmd = '/opt/openhab18/configurations/scripts/curl_devinfo.sh pumpcost ’ + ftmp
executeCommandLine(cmd)
logInfo(“openhab”, cmd)

my script is

/usr/bin/curl -d “{ “auth_token”: “YOUR_AUTH_TOKEN”, “$1”: “$2” }” -H “Content-Type: application/json” http://localhost:3030/widgets/devinfo

devinfo is basically a Number widget in dashing.io

my sendhttpPost works the same way, can post long json of 30 points of graph data just fine, but posting a number to my widget doesn’t always work. can’t make them update on schedule.
when i post from the command line like

./curl_devinfo.sh pumpcost 12.3

it works perfectly every time.
so i don’t think this is a dashing dashboard issue.
pulling my hair out on this one!
any thoughts?
thanks

By this do you mean that you have verified that OH is running the exec but the data isn’t getting to your dashboard or OH isn’t even calling the exec?

If it is former, change your code slightly to the following:

val String results = executeCommandLine(cmd, 5000)
logInfo("openhab", cmd +"\n" + results)

and check the logs for errors returned by the command.

If it is the latter the problem is that what ever rule that the above code resides in is not being triggered all the times you think it should be.

thanks, i’ve noticed you suggest that before, not sure if there’s an error here or not.
again, i get the same unreliable results from using json with a sendHttpPost command.
but i can also reliable post 30 points of data to a graph widget using sendHtppPost (in json format).
here’s the results from the “results”

2016-03-02 11:29:00.462 Process exited with an error: 0 (Exit value: 0)
2016-03-02 11:29:00.463 cmd =/opt/openhab18/configurations/scripts/curl_devinfo.sh pumpcost 1.78results = % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 55 0 0 100 55 0 8931 --:–:-- --:–:-- --:–:-- 9166

is that error 0 really an error? the transfer data looks appropriate for whatever i’m sending, depending if it’s short command like this or long string of data points…
the rule is working because i’m always logging the data at the same time and it never behaves anomalously.
just doesn’t reliable show up in the dashboard. though executing the script from a command line is flawless.

If the rule is always executing and if the results from calling executeCommandLine always show the command was successful and when the call to executeCommandLine always returns an exit value of 0 whether it works or not, the only conclusion I can make is that the problem isn’t happening within openHAB and instead is happening somewhere between your script and your dashboard.

script works from the command line perfectly every time, with the exact same syntax from inside the rule, plus “./” in the front…
hence the frustration.
i’m concerned it’s the way the exec binding interacts with my system, because i don’t know how to address that.
so i tried using the sendHttpPost and the executeCommandLine/script and yet they both function, or don’t function the same way.
i uninstalled curl but kept a copy in an OH directory, changing owner, no difference.
reinstalled curl, no difference.
it’s not that it doesn’t work, the data shows up, eventually, or sporadically.
i have it posting every minute with a chron rule and when i look at the dashboard any of the 5 values in that one widget may or may not be showing.

i’ll take this up from the dashboard side. some people use dashing with OH to make some nice dashboards. i’ve looked at some of that code but there is nothing tricky going on anywhere, it seems. hence my system concerns again.

One thing to note is that when openHAB executes something it does it as the openhab user. So often permission problems will crop up because of that. But having it work sometimes but not work all of the time is not going to be caused by user permission problems. It will either always work or always not work. And if you run your script and there is a permission problem there will be an error message in the results saying you don’t have permission to read, write, or execute.

If it works sometimes but not other times when called from openHAB, and openHAB is calling the script every time it is supposed to, and the script is returning text that indicates that it is executing successfully every time but the data is not getting to the dashboard every time, I don’t know what to say except I don’t see how the problem could be openHAB. It just doesn’t work like that. Either it works or it doesn’t.

If the problem were openHAB I would expect to see it either fail to call the script when it is supposed to or see an error when it tries to call the script. So either the script isn’t generating errors and just failing silently and looking like it is running successfully or the script is running successfully and somehow the data is not getting to its destination. You might try adding some echos and checks to your script to make sure this isn’t the case.

When you execute the script from the command line, do you execute it just once or do you execute it every minute for awhile, duplicating what openHAB is doing? Executing it just the one time really doesn’t prove that you are not having the problem because it works for openHAB at least some of the time.

that’s a good point. i can write a script to run the script a lot. but it posts so quick and perfect by command line, and so intermittently from OH that i wasn’t drawn to do that so far.
usually when things aren’t always working or not working i’m concerned about race situations of some nature. this would have to be external to OH. OH certainly seems to be doing it’s job, judging from the logs.

these aren’t the first posts to the dashboard. in fact, they are after a couple graphs get updated. could i be pushing them too fast for something down stream? i’ll move them to the top.
also, i’ll go and check all the posts for errors,
will start using a separate log file for clarity.
but, no exec binding issues come to mind? seems there are often version conflicts and such
then again, the sendPostHTTP doesn’t use that, i think. and i had the same results with that.
cool, something to work with…

OK, got it.
i was sending multiple sendHttpPostRequest() to the same widget with only a few lines of code between them and they would work unreliably. they were properly constructed, stand alone posts, but only the first one worked reliably.
i strung the json all together after conditioning the values and then send it one time, no problems.
perhaps this is an obvious thing not to do, but lesson learned.
seems like i got the same bad behavior when i used the curl script and executeCommandLine instead of sendHttpPostRequest, so the problem is likely outside of OH.

thanks for the help,
Mike

Discovering and debugging timing problems like this are almost never obvious.

I’m glad you got it to work.