Shared script behave differently depending on the way it is lauched

Ignition Version : 7.8.3

Hello all,

I have a stange behavior with shared scoped scripts. I have made a simple one to show the problem:

In Shared, i have a simple script :

def refreshTest():
retour = system.net.httpGet(“https://github.com”)
return retour

When I call it from the Script Console or a Button, it works just fine. When I put it in a TagEvent Script or Gateway timer script, the script fails and the logs read :

13:42:13 ScriptDispatcher ([#######]WS/TOP_TEST 1, valueChanged) Error executing tag event script: null
Traceback (most recent call last):

File “<tagevent:valueChanged>”, line 6, in valueChanged
File “<module:shared.WS>”, line 72, in refreshTest
IOError: github.com

at org.python.core.Py.fromIOException(Py.java:215)
at org.python.core.Py.IOError(Py.java:178)
at com.inductiveautomation.ignition.common.script.builtin.AbstractNetUtilities.httpGet(AbstractNetUtilities.java:260)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction.call(PyReflectedFunction.java:186)
at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.call(ScriptManager.java:427)
at org.python.core.PyObject.call(PyObject.java:387)
at org.python.core.PyObject.call(PyObject.java:391)
at org.python.pycode._pyx10.refreshTest$3(<module:shared.WSEDF.WS>:74)
at org.python.pycode._pyx10.call_function(<module:shared.WSEDF.WS>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:120)
at org.python.core.PyFunction.call(PyFunction.java:307)
at org.python.pycode.pyx9.valueChanged$1(<tagevent:valueChanged>:6)
at org.python.pycode.pyx9.call_function(<tagevent:valueChanged>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:301)
at org.python.core.PyFunction.function___call
(PyFunction.java:376)
at org.python.core.PyFunction.call(PyFunction.java:371)
at org.python.core.PyFunction.call(PyFunction.java:361)
at org.python.core.PyFunction.call(PyFunction.java:356)
at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:636)
at com.inductiveautomation.ignition.common.sqltags.scripts.TagScriptManager$FunctionInvokerImpl.run(TagScriptManager.java:375)
at com.inductiveautomation.ignition.common.sqltags.scripts.AbstractTagScript.invoke(AbstractTagScript.java:34)
at com.inductiveautomation.ignition.common.sqltags.scripts.TagScriptManager$Task.invoke(TagScriptManager.java:345)
at com.inductiveautomation.ignition.common.sqltags.scripts.TagScriptManager$TagScriptDispatcher.run(TagScriptManager.java:310)
at com.inductiveautomation.ignition.common.execution.impl.BasicExecutionEngine$ThrowableCatchingRunnable.run(BasicExecutionEngine.java:537)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)|

In both cases, i use the exact same instruction to execute my shared script :

shared.WS.refreshTest()

The Gateway and the client both run on the same machine (same internet settings for proxy).
My guess was that the Internet proxy settings would not apply to the JVM so I added those lines in the ignition.conf settings:

wrapper.java.additional.5=-Dhttp.proxyHost=myProxy
wrapper.java.additional.6=-Dhttp.proxyPort=myProxyPort
wrapper.java.additional.7=-Dhttp.nonProxyHosts=“localhost|127.0.0.1”
#wrapper.java.additional.8=-Dcom.sun.net.ssl.checkRevocation=false

with no luck.

I’m a bit stuck with this. If anyone has an idea about all this, it would be very welcomed.

Regards

What OS are you running on?

And did you try with an http address too?

If you’re running on Windows f.e. the Ignition gateway will run under a different user than the client, and perhaps the service user doesn’t have access to the SSL certificates needed to make a connection with an https address.

You could also try more native python clients, though I’ve also had https issues with those. https://docs.python.org/2.5/lib/module-httplib.html

I indeed use Windows. I gave a try to the user account name and changed it to my windows account name.
The service works fine but the webservice still not goes out.

The idea to try an http address was fine has it could confirm that it could work like that (the http request can go outand retreive data that indicate that the document was moved to the https address)

When using httpS
then also add these proxies. ( note the S in Dhttps)
wrapper.java.additional.10=-Dhttps.proxyHost=xx.xx.xx.xx
wrapper.java.additional.11=-Dhttps.proxyPort=xx

1 Like

I am pretty sure system.net.getHttp is not recommended anymore. Use https://docs.inductiveautomation.com/display/DOC80/system.net.httpClient and from there use get. Perhaps that will fix the issue.

Thanks, but we are still v7. And looking over the forum for a week I could not get my https get instructions to complete without the IOError.
Adding the proxies did indeed fix it for me (adding the https proxies)

Hello,

Is the proxy additionnal parameter still available for version 8.1 ?

On a new server, I installed a 8.1 version and added the proxy parameters (Dhttp(s).proxyHost and Dhttp(s).proxyPort) in the ignition.conf file. From there, the httpGet won’t work (IO Error).

On the same server, when I restore the 7.8.3 version, it works perfectly.

So my problem seems to be located on Ignition but I’ve tried all that was suggested here without success.

Anyone have an idea about this ? Any help will be greatly appréciated.

Regards.

I believe those properties will work with the HttpClient class, which you can use via the system.net.httpClient script function. Basically, you create a client object, and then you make your GET call via that. There are some good examples in the documentation, hopefully it is enough to get you going…