[Bug] Web Endpoint API call in scripting

1. The behavior you unexpectedly encountered
When trying to make a simple HTTP get to work I receive an IO Error.

2. The behavior you were expecting to see
The output to be displayed in the console. Example below
{“coord”:{“lon”:-80.49,“lat”:43.45},“weather”:[{“id”:800,“main”:“Clear”,“description”:“clearsky”,“icon”:“01d”}],“base”:“stations”,“main”:{“temp”:275.95,“pressure”:1022,“humidity”:55,“temp_min”:274.15,“temp_max”:277.15},“visibility”:14484,“wind”:{“speed”:4.1,“deg”:170},“clouds”:{“all”:1},“dt”:1542996000,“sys”:{“type”:1,“id”:3730,“message”:0.0045,“country”:“CA”,“sunrise”:1542975994,“sunset”:1543009819},“id”:5992996,“name”:“Kitchener”,“cod”:200}

3 A list of the steps you took that exposed the issue
Code:
data = system.net.httpGet(‘http://api.openweathermap.org/data/2.5/weather?q=kitchener,CA&appid=a450c5b195eaa265e77d8994b365fc91’)
print data

If I run this code in the script console it executes.
If I run this code behind a button in a vision window in 8.0 it executes.
If I run this code behind a button in perspective view it fail.

Error:
com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File “”, line 5, in runAction IOError: api.openweathermap.org

Is there any more to that stack trace?

If you run this script from a tag change script does it also error out?

Didn’t want to flood the intitial comment with the whole trace.
Here it is,

com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File “”, line 5, in runAction IOError: api.openweathermap.org
at org.python.core.Py.fromIOException(Py.java:245)
at org.python.core.Py.IOError(Py.java:212)
at com.inductiveautomation.ignition.common.script.builtin.AbstractNetUtilities.httpGet(AbstractNetUtilities.java:257)
at jdk.internal.reflect.GeneratedMethodAccessor43.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction.call(PyReflectedFunction.java:188)
at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.call(ScriptManager.java:436)
at org.python.core.PyObject.call(PyObject.java:480)
at org.python.core.PyObject.call(PyObject.java:484)
at org.python.pycode.pyx67.runAction$1(:6)
at org.python.pycode.pyx67.call_function()
at org.python.core.PyTableCode.call(PyTableCode.java:171)
at org.python.core.PyBaseCode.call(PyBaseCode.java:308)
at org.python.core.PyFunction.function___call
(PyFunction.java:471)
at org.python.core.PyFunction.call(PyFunction.java:466)
at org.python.core.PyFunction.call(PyFunction.java:456)
at org.python.core.PyFunction.call(PyFunction.java:451)
at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:674)
at com.inductiveautomation.ignition.common.script.ScriptManager$ScriptFunctionImpl.invoke(ScriptManager.java:790)
at com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper.invoke(ScriptFunctionHelper.java:82)
at com.inductiveautomation.perspective.gateway.action.ScriptAction.runAction(ScriptAction.java:64)
at com.inductiveautomation.perspective.gateway.action.ActionDecorator.runAction(ActionDecorator.java:18)
at com.inductiveautomation.perspective.gateway.action.SecuredAction.runAction(SecuredAction.java:43)
at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.lambda$call$0(ActionCollection.java:257)
at com.inductiveautomation.perspective.gateway.api.LoggingContext.mdc(LoggingContext.java:54)
at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.call(ActionCollection.java:246)
at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.call(ActionCollection.java:215)
at com.inductiveautomation.perspective.gateway.threading.BlockingTaskQueue$TaskWrapper.run(BlockingTaskQueue.java:154)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: org.python.core.PyException: Traceback (most recent call last): File “”, line 5, in runAction IOError: api.openweathermap.org
… 34 common frames omitted

Ill try from a tag change script and get back to you.

Attaching logs.
Ignition-BSIGGWSD20_Ignition_logs_20181123-1452.idb (1.8 MB)

Update: It also occurs in a tag change script

So, the difference here is that when you run from the script console or a Vision button it’s running on the computer you’re running the client/designer on, whereas with the Perspective button and the tag change script it’s running on the gateway itself.

There seems to be something about your gateway preventing this network call from happening successfully. Firewall maybe, or something about the permissions setup and the Ignition Gateway running as a service… hard to say.

Hi Kevin, thanks for the response. I assumed it was something to do with the scope of execution just didn’t realize the difference in execution. Ill figure it out from here.

Thanks.

Is there something I should do to close out this thread?

Couple other questions.
Does this mean that a Perspective project would produce more load on a gateway than a comparable Vision project. If I am fully understanding the implication every single script calls need to go to the server.
Is there no way to push any of the scripting within a Perspective view client side?

Yeah I guess you could say it produces more load, but it's not really something you should be too concerned with. Perspective will scale out to allow more clients than Vision ever did.

Every Perspective client has its own session running on the server where a lot of bookkeeping, script execution, etc... happens. It's not possible to move script execution to the client (and even if it were that's not something you'd want because it would be a security issue).

Hi Kevin,
Just another thought. If I wanted to access a mobile device’s camera to take a picture. How would this work with all of the scripting code being run on the server? I understand there is the barcode scan ‘action’, which works if you are within the android app for example. But I don’t just want to read a barcode I want to take a picture and save it into a database.

My initial thought was to use a python library like SimpleCV but based on this last discussion the code wouldn’t actually end up accessing the devices camera but something on the server itself.

I feel like I am missing something very obvious when it comes to using the mobile device camera in 8.0?
Is there a feature I have completely glanced over or am I thinking about doing sometime that isn’t really possible.

Thanks

Nothing you're missing - it's just not implemented yet. Image capture will be implemented as an 'action', which you would fire whenever desired using action configuration in Perspective. If your user is inside of a mobile application, it will then fill out to the camera, and allow image capture natively. The handoff of that image back to the application is the "tricky" part, and something that's still being ironed out.

1 Like

Hi,
I have been away from the Beta for a little while. I have a project starting up now where the feature of the mobile camera was required for taking pictures of defect items. I downloaded the nightly build of the beta on Friday and I still do not see an option for accessing the device camera.
Has this been completed? Or is it still in development?
Is there a better source for updates to the Beta functionality?

Wasn’t sure where else to go to get some info on this. It’s part of the critical path of the project and we were hoping to begin development soon.
Thanks

Hi Ryan,

There have been changes, but we have not yet published any direct camera access functionality.

What is your use case? Do you need to access the camera directly (as in, be able to launch the camera to take a picture), or 'choose' images that were taking from some sort of image browser? Both?

Is there a better source for updates to the Beta functionality?

The best source is probably in the nightly changelogs, but we could probably make that easier by posting all the logs in a single thread that is sticky or something. I'll see if we can make that happen going forward so it's easier to search a single place.

Its going to be on a rugged tablet.
Yes we will need to launch the camera and retrieve the picture to save into the database.