Help with Ignition httpClient calls not working

Hey folks,

Running into difficulty deploying system.net.http* scripts on client network. Attempting to run the following test call in 3 different scenarios:

# Create the JythonHttpClient.
client = system.net.httpClient()
 
# Sent a GET request.
response = client.get("https://httpbin.org/get", params={"a": 1, "b": 2})

print response

# Validate the response.
if response.good:
    # Do something with the response
    print response.json['args']['a']

Test 1: Executing from script console on my PC: Success.
Test 2: Running the same call from Postman on PC on client network: Success.
Test 3: Executing from any Ignition source on client network: Failure. See below.

java.io.IOException: java.io.IOException: Unable to GET https://httpbin.org/get?a=1&b=2

Seems to be an issue running the calls from Ignition on client network. IT's response:

I suspect that you are using some port, other than 443, for API calls, because 443 would route those requests out through the proxy server.

Any advice on how to troubleshoot this behavior or narrow down the point of failure?

Thank you in advance.

If this is like a true old school proxy setup and not something transparent, i.e. there's a host/IP for the proxy server that you can get from IT, you could try adding something like this at the beginning of your script:

from java.lang import System

System.setProperty("https.proxyHost", "get.thisfromit.com")

(you need the hostname/IP from IT)

2 Likes

Good suggestion, thanks Kevin. I've sent in a request to IT and will see what we get back.

IT returned a proxy and port. I found success in using either:

from java.lang import System
System.setProperty("https.proxyHost", "itProxyAddress")
System.setProperty("https.proxyPort", "itProxyPort")

Or

client = system.net.httpClient(proxy="https://itProxyAddress:itProxyPort")

Is there an advantage to choosing one over the other in this situation?

Thank you again, Kevin.

1 Like

A third option would be to set it permanently in ignition.conf. I think it depends whether you will always need this set up for any HTTP(S) call on this gateway/network or not.

edit: err, and where the calls originate from. Setting it in ignition.conf only helps when they originate from gateway scope, as opposed to Vision Client or Designer.

It would be for any call on the network, yeah. Setting it in the conf makes sense.
Which variables would I need to add for that solution?

You would add entries in the "Java Additional Parameters" section like this:

wrapper.java.additional.8=-Dhttps.proxyHost=foo
wrapper.java.additional.9=-Dhttps.proxyPort=1234

(use two unused numbers)

again just to clarify - this will only be for gateway-scoped stuff. A call from the Designer script console wouldn't end up using this.

3 Likes

Awesome. Thank you, again, for taking the time to lay that out for me. Much appreciated.