# java.io.IOException:Unable to GET

**URL:** <https://forum.inductiveautomation.com/t/java-io-ioexception-unable-to-get/52722>\
**Category:** Ignition\
**Created:** [November 4, 2021, 1:31pm UTC](https://forum.inductiveautomation.com/t/java-io-ioexception-unable-to-get/52722 "2021-11-04T13:31:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bogdan](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@Bogdan](https://forum.inductiveautomation.com/u/Bogdan)\
**Post date:** [November 4, 2021, 1:31pm UTC](https://forum.inductiveautomation.com/t/java-io-ioexception-unable-to-get/52722/1 "2021-11-04T13:31:31Z")

</div>

Hi guys,

Got a gateway here that need to do allot of API calls.  
Using the **system.net.httpGet()** everything runs smoothly but slower.  
When I use **system.net.httpClient()** things are moving much faster but I receive this error:

1.Error executing tag event script: java.io.IOException: java.io.IOException: Unable to GET “the url”  
2.Clock drift, degraded performance, or pause-the-world detected. Max allowed deviation=1000ms, actual deviation=64534ms

I’ve created the following test tags that need to run 10k API call each.

Here I’m using **system.net.httpClient(),** and at about 5k I’m getting the error  
 ![1](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/d/7d11495034ff9d83c8c545328bdf01849b2e4ad3.png)

Here I’m using **system.net.httpGet(),** and it successfully finish the job.  
 ![2](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/6/46ec4ad80ce2c6d63efbca5cf0d17861e52e7711.png)  
[ATO-MESOPC01-Prod\_thread\_dump20211104-151711.json](https://forum.inductiveautomation.com/uploads/short-url/vDJRDGR7zdoSZlB8tMHoncLQCYw.json) (120.6 KB)

Any idea how to solve this one?

---

<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:** [November 4, 2021, 1:32pm UTC](https://forum.inductiveautomation.com/t/java-io-ioexception-unable-to-get/52722/2 "2021-11-04T13:32:38Z")

</div>

You’ll have to post some code examples. It seems like you’ve either created a memory leak in your code or discovered one in ours.

---

<div class="post-metadata">

**Author:** ![Bogdan](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@Bogdan](https://forum.inductiveautomation.com/u/Bogdan)\
**Post date:** [November 4, 2021, 2:03pm UTC](https://forum.inductiveautomation.com/t/java-io-ioexception-unable-to-get/52722/3 "2021-11-04T14:03:44Z")

</div>

This is the code that is running with **httpClient**

The value change event script on the tag

```auto
	if str(currentValue.quality).upper() == 'GOOD' and str(previousValue.quality).upper() == 'GOOD':	
		if currentValue.value == 1:
			i = 1
			while i < 10000:
				i += 1
				test = L2L.API.getAreas()
				system.tag.write("[.]newAPI", i)

```

**Gateway Scripts**

L2L.API.GetAreas:

```auto
def getAreas(extraURL = None, extraParameters = None):
	# Default URL
	url = "%(url)s%(api)sareas/?auth=%(auth)s&site=%(site)s&fields=%(fields)s"
	
	# Default parameters
	parameters = {}
	parameters["fields"] = "code"
		
	# Adding extra values ​​to the request, overithing if already defined
	if isinstance(extraURL, str):
		url = url + extraURL
	if isinstance(extraParameters, dict):
		parameters.update(extraParameters)

	return L2L.HttpHelper.clientHttpRequest("GET", url, parameters)

```

L2L.HttpHelpper:

```auto
logger = system.util.getLogger('L2L-HttpHelper')

# Creating an instance of httpClient
client = system.net.httpClient()

# Define a dictionary with available methods.
requestMethods = {}
requestMethods["GET"] = client.get
requestMethods["POST"] = client.post

def getSiteVariables():
	# Define a tuple with L2L parameters.
	tags = ("url", "auth", "site", "api")
	
	# Generate a list with path of parameters and read values.
	tagPaths = []
	for tag in tags:
		tagPaths.append("Config/L2L/%s" %tag)
	tagValues = system.tag.readAll(tagPaths)
	
	# Generate a dictionary.
	l2lParameters = {}
	idx = 0
	for tag in tags:
		l2lParameters[tag] = tagValues[idx].value
		idx += 1
		
	return l2lParameters
	
def clientHttpRequest(method, url, paramaters):
	# Cheking parameters type.
	if not isinstance(method, str):
		logger.error("Function clientHttpRequest recieved invalid parameter type for (method), expected str got " + str(type(method)))
		return None
	if not isinstance(url, str):
		logger.error("Function clientHttpRequest recieved invalid parameter type for (url), expected str got " + str(type(url)))
		return None
	if not isinstance(paramaters, dict):
		logger.error("Function clientHttpRequest recieved invalid parameter type for (paramaters), expected dict got " + str(type(paramaters)))
		return None

	# Generating dictionary with all parameters
	l2lParameters = getSiteVariables()
	l2lParameters.update(paramaters)
	
	# Attaching parameters to url and replace spaces.
	try:
		l2lURL = url %l2lParameters
		formatedURL = l2lURL.replace(" ", "%20")
	except Exception, e:
		logger.error("Function clientHttpRequest failed to generate the L2L url.")
		raise Exception(str(e))
	
	# Run the http request.
	try:
		response = requestMethods[method.upper()](formatedURL)
		if response.isGood():	
			responseData = response.getJson()
			if responseData["success"]:
				return responseData["data"]
			else: 
				logger.error("Function clientHttpRequest " + str(responseData["error"])) 	
		else:
			logger.error("Function clientHttpRequest response.isGood: " + str(response.isGood()))
	except Exception, e:
		logger.error("Function clientHttpRequest failed to run the http request: "+ str(e))
		raise Exception(str(e))
	
	return None
	
def l2lTimeFormat(timeStamp):
	try:
		return system.date.format(timeStamp, "yyyy-MM-dd HH:mm")
	except Exception, e:
		logger.error("Function l2lTimeFormat failed to format the timeStamp: "+ str(e))
		raise Exception(str(e))
		

```

Thanks for the support 😃

---

<div class="post-metadata">

**Author:** ![Bogdan](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@Bogdan](https://forum.inductiveautomation.com/u/Bogdan)\
**Post date:** [November 12, 2021, 8:46am UTC](https://forum.inductiveautomation.com/t/java-io-ioexception-unable-to-get/52722/4 "2021-11-12T08:46:03Z")

</div>

Hi Kevin, any resolution on this topic?

---

<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:** [November 12, 2021, 1:44pm UTC](https://forum.inductiveautomation.com/t/java-io-ioexception-unable-to-get/52722/5 "2021-11-12T13:44:09Z")

</div>

No, sorry, I can’t see anything obviously wrong. I thought maybe you were doing an async call with `system.net.httpClient` and allowing them to pile up in memory or something but that’s not the case.

I think you’ll have to work with support to further diagnose and maybe they will try to reproduce this.

---

<div class="post-metadata">

**Author:** ![Ryan\_Shaw](https://avatars.discourse-cdn.com/v4/letter/r/dbc845/32.png) [@Ryan\_Shaw](https://forum.inductiveautomation.com/u/Ryan_Shaw)\
**Post date:** [June 14, 2023, 2:27pm UTC](https://forum.inductiveautomation.com/t/java-io-ioexception-unable-to-get/52722/6 "2023-06-14T14:27:16Z")

</div>

Hi Bogdan. I'm getting the same error message today on Ignition 8.1.23. The script I'm running works when I execute it in a script console, but it fails when running from a scheduled gateway script. Did you ever contact support for an explanation?
