# system.net.httpClient() causes java.io.IOException while system.net.httpGet() works fine

**URL:** <https://forum.inductiveautomation.com/t/system-net-httpclient-causes-java-io-ioexception-while-system-net-httpget-works-fine/45547>\
**Category:** Ignition\
**Tags:** ignition80, scripting\
**Created:** [April 13, 2021, 7:09pm UTC](https://forum.inductiveautomation.com/t/system-net-httpclient-causes-java-io-ioexception-while-system-net-httpget-works-fine/45547 "2021-04-13T19:09:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![msella](https://avatars.discourse-cdn.com/v4/letter/m/df705f/32.png) [@msella](https://forum.inductiveautomation.com/u/msella)\
**Post date:** [April 13, 2021, 7:09pm UTC](https://forum.inductiveautomation.com/t/system-net-httpclient-causes-java-io-ioexception-while-system-net-httpget-works-fine/45547/1 "2021-04-13T19:09:31Z")

</div>

I am currently able to pull in data from the [JIRA REST API](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/) using system.net.httpGet(), but when I try the same request with system.net.httpClient().get() I receive a java.io.IOException GOAWAY.

```auto
# Working request
url = "URL"
headers = {"Accept": "application/json"}
contentType = "application/json"
username = "USER"
password = “API_KEY”
response = system.net.httpGet(url = url, contentType = contentType, headerValues = headers, username = username, password = password)

```

```auto
# Broken request
url = "URL"
headers = {"Accept": "application/json"}
username = "USER"
password = “API_KEY”
response = system.net.httpClient().get(url = url, headers = headers, username = username, password = password)

```

I have checked for header differences between the two calls and found none. I also tried changing the redirect\_policy which led to no improvement. Is there a difference with how the Java 11 HttpClient makes the connection with the API server that differs from the old system.net.httpGet() that might lead to this issue?

Note: This is on 8.0.17.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 13, 2021, 8:31pm UTC](https://forum.inductiveautomation.com/t/system-net-httpclient-causes-java-io-ioexception-while-system-net-httpget-works-fine/45547/2 "2021-04-13T20:31:57Z")

</div>

`httpClient` is using HTTP/2, which the target server is apparently not accepting and apparently not negotiating correctly. Unfortunately, the solution (telling HttpClient to only use HTTP/1) is not currently viable due to a bug:

> [@\[BUG-16787\] system.net.httpClient() HttpClient.Version customizer](http://forum.inductiveautomation.com/t/bug-16787-system-net-httpclient-httpclient-version-customizer/39138):
>
> I need to set my http clients version, similar to: HttpClient.newBuilder() .version(Version.HTTP\_1\_1) so I defined a customizer function to set it, but I cannot for the life of me figure out what I need to import or define so that I can specify the version parameter needed in the .version method. Here is my callable, but I just cant seem to figure it out. def clientCustomizer(client): return client.version(HttpClient.Version.versionOf("HTTP\_1\_1")) If anyone has any ideas they are great…

Until that bug is fixed, you'll likely have to keep using `httpGet`.

---

<div class="post-metadata">

**Author:** ![msella](https://avatars.discourse-cdn.com/v4/letter/m/df705f/32.png) [@msella](https://forum.inductiveautomation.com/u/msella)\
**Post date:** [April 13, 2021, 8:41pm UTC](https://forum.inductiveautomation.com/t/system-net-httpclient-causes-java-io-ioexception-while-system-net-httpget-works-fine/45547/3 "2021-04-13T20:41:00Z")

</div>

Thank you for the explanation - I’ll be looking out for an update in the future. In the meantime, is there a compatible library I could use to execute a “multipart/form-data” POST with? It’s the reason why I wanted to try using system.net.httpClient() in the first place. I don’t believe system.net.httpPost() will work.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 13, 2021, 9:34pm UTC](https://forum.inductiveautomation.com/t/system-net-httpclient-causes-java-io-ioexception-while-system-net-httpget-works-fine/45547/4 "2021-04-13T21:34:05Z")

</div>

Actually, `httpClient` doesn't do you any favors with `multipart/form-data` at present either (☹). I've seen customers use `requests` in Ignition directly; you can access `pip` to install it more easily using the method outlined here:

> [@Procedure for installing python libraries from source](http://forum.inductiveautomation.com/t/procedure-for-installing-python-libraries-from-source/26022/2):
>
> There’s actually a procedure you can use to use pip from within Jython to install packages, then link Ignition’s Jython lib to an-off-the-shelf Jython lib and use that…however, the article specifically calls out the twilio module as not working, because one of its dependencies, cffi, has C dependencies (IE, won’t work in Jython). For posterity, here’s the procedure, copied verbatim from an internal document: 0) On the server, install Java 8 if you haven’t already. Download the full Jython 2.…

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [July 19, 2022, 10:43pm UTC](https://forum.inductiveautomation.com/t/system-net-httpclient-causes-java-io-ioexception-while-system-net-httpget-works-fine/45547/5 "2022-07-19T22:43:12Z")

</div>

Hi @paul-griffith is that [BUG-16787] still not fixed?  
I’m on 8.1.17 and trying to use httpClient.post and i think i am running into the same problem in this thread.

**This works:**

```auto
resp = system.net.httpPost(url=postUrl, contentType="application/json", postData=payload, username="REDACTED", password="REDACTED", throwOnError=False)

```

**This doesn’t:**

```auto
client = system.net.httpClient()
response = client.post(url=postUrl, data=payload, username="REDACTED", password="REDACTED")

```

I get the following error:

```auto
com.inductiveautomation.ignition.common.script.JythonExecException
Traceback (most recent call last):
  File "<function:runAction>", line 81, in runAction
  File "<function:runAction>", line 67, in testSendMsg3
java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: java.io.IOException: Can't get stream 1: java.io.EOFException: EOF reached while reading

	caused by org.python.core.PyException
Traceback (most recent call last):
  File "<function:runAction>", line 81, in runAction
  File "<function:runAction>", line 67, in testSendMsg3
java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: java.io.IOException: Can't get stream 1: java.io.EOFException: EOF reached while reading

	caused by ExecutionException: java.io.IOException: Can't get stream 1: java.io.EOFException: EOF reached while reading
	caused by IOException: Can't get stream 1: java.io.EOFException: EOF reached while reading
	caused by EOFException: EOF reached while reading

Ignition v8.1.13 (b2021122109)
Java: Azul Systems, Inc. 11.0.13

```

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 19, 2022, 10:47pm UTC](https://forum.inductiveautomation.com/t/system-net-httpclient-causes-java-io-ioexception-while-system-net-httpget-works-fine/45547/6 "2022-07-19T22:47:15Z")

</div>

Your error message says you’re on 8.1.13.

Since 8.1.16 there is a `version` parameter you can set when using `system.net.httpClient`: [system.net.httpClient - Ignition User Manual 8.1 - Ignition Documentation (inductiveautomation.com)](https://docs.inductiveautomation.com/display/DOC81/system.net.httpClient)

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [July 19, 2022, 10:59pm UTC](https://forum.inductiveautomation.com/t/system-net-httpclient-causes-java-io-ioexception-while-system-net-httpget-works-fine/45547/7 "2022-07-19T22:59:06Z")

</div>

Thanks Kevin,

My bad, i forgot what gateway i was testing this on. There are 5 gateways on this project and i updated all of them (except this one) to 8.1.17 recently.  
I’ll try update it and see how we go with that new version option.  
Cheers

**Edit:** Yep that worked fine forcing version to “HTTP\_1\_1”. Cheers
