# API connection error via scheduled event script

**URL:** <https://forum.inductiveautomation.com/t/api-connection-error-via-scheduled-event-script/104720>\
**Category:** Ignition\
**Created:** [April 4, 2025, 3:11pm UTC](https://forum.inductiveautomation.com/t/api-connection-error-via-scheduled-event-script/104720 "2025-04-04T15:11:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![freggianini](https://avatars.discourse-cdn.com/v4/letter/f/e95f7d/32.png) [@freggianini](https://forum.inductiveautomation.com/u/freggianini)\
**Post date:** [April 4, 2025, 3:11pm UTC](https://forum.inductiveautomation.com/t/api-connection-error-via-scheduled-event-script/104720/1 "2025-04-04T15:11:29Z")

</div>

Hello,

in a scheduled event script, i try to connect via an API with **system.net.httpGet()**.

When i try to connect, suddenly the designer i can't connect to the gateway anymore. I have **"Gateway connection lost - post error, error code = 400"**

Below the script i try to run.  
Basycally i want to connect to an API and then searching the intersection between rows and column, copy the respective value, and writing it into a tag.

Appreciate if anybody could help.

* * *

```python
from datetime import datetime, timedelta

# API URL
url = "http://abc"

# Dictionary of columns and corresponding tags
colonne_tag = {
    "column_name": "xxx/Consumi/kWh_60"
}

# Request data from API
response = system.net.httpGet(url)
if response and response.strip():
    # Get the current time minus two hours
    ora_target = (datetime.now() - timedelta(hours=2)).strftime("%d-%m-%Y;%H:00")

    # Split data into rows using CRLF
    righe = response.split("\r\n")

    # Check if there is data and at least a header row
    if len(righe) >= 2:
        # Get the header and map columns
        intestazione = righe[0].split("\t")
        colonne_mappa = {colonna: idx for idx, colonna in enumerate(intestazione) if colonna in colonne_tag}

        # Search for the row with the target date and time
        for riga in righe[1:]:
            # Ignore rows containing "!"
            if "!" in riga:
                continue

            colonne = riga.split("\t")
            if len(colonne) == 22 and colonne[0] + ";" + colonne[1] == ora_target:
                for colonna, indice in colonne_mappa.items():
                    try:
                        valore_colonna = colonne[indice].replace(",", ".") # Convert value to standard numeric format
                        valore_float = float(valore_colonna)

                        # Write the value to the tag with the specific timestamp
                        system.tag.storeTagHistory("prov:Local_SQL", [colonne_tag[colonna]], [datetime.now() - timedelta(hours=2)], [valore_float])
                    except (ValueError, IndexError):
                        continue # Ignore conversion or index errors

```

---

<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 4, 2025, 3:43pm UTC](https://forum.inductiveautomation.com/t/api-connection-error-via-scheduled-event-script/104720/2 "2025-04-04T15:43:45Z")

</div>

What does the gateway's CPU and memory usage look like when this scheduled event is running? How large is the response object from this API?

---

<div class="post-metadata">

**Author:** ![freggianini](https://avatars.discourse-cdn.com/v4/letter/f/e95f7d/32.png) [@freggianini](https://forum.inductiveautomation.com/u/freggianini)\
**Post date:** [May 22, 2025, 10:41am UTC](https://forum.inductiveautomation.com/t/api-connection-error-via-scheduled-event-script/104720/3 "2025-05-22T10:41:45Z")

</div>

> [@paul-griffith](#):
>
> gateway's CPU and memory usage

gateway's CPU and memory usage looks regular, without peaks.

The API answer is below.

> **API answer**
>
> 12-01-2025;00:00;38,50; ;18,70; ;32,00; ;44,00; ;20,00; ;25,00; ;29,00; ;6,00; ;75,00; ;62,00; ;331,50; 12-01-2025;01:00;37,50; ;18,80; ;31,00; ;42,00; ;19,00; ;27,00; ;28,00; ;6,00; ;73,00; ;62,00; ;325,50; 12-01-2025;02:00;38,40; ;18,60; ;32,00; ;42,00; ;20,00; ;25,00; ;28,00; ;6,00; ;71,00; ;61,00; ;323,40; 12-01-2025;03:00;37,10; ;18,90; ;31,00; ;43,00; ;19,00; ;27,00; ;27,00; ;6,00; ;68,00; ;60,00; ;318,10; 12-01-2025;04:00;38,10; ;18,60; ;32,00; ;43,00; ;21,00; ;25,00; ;28,00; ;6,00; ;70,00; ;61,00; ;324,10; 12-01-2025;05:00;38,70; ;18,60; ;31,00; ;43,00; ;18,00; ;27,00; ;27,00; ;6,00; ;68,00; ;61,00; ;319,70; 12-01-2025;06:00;37,40; ;18,70; ;33,00; ;42,00; ;21,00; ;25,00; ;29,00; ;6,00; ;68,00; ;61,00; ;322,40; 12-01-2025;07:00;38,00; ;18,90; ;31,00; ;43,00; ;19,00; ;27,00; ;28,00; ;6,00; ;68,00; ;60,00; ;320,00; 12-01-2025;08:00;37,70; ;18,70; ;32,00; ;43,00; ;19,00; ;25,00; ;28,00; ;6,00; ;69,00; ;62,00; ;321,70; 12-01-2025;09:00;38,20; ;18,70; ;32,00; ;42,00; ;21,00; ;27,00; ;29,00; ;6,00; ;72,00; ;61,00; ;328,20; 12-01-2025;10:00;38,50; ;18,80; ;32,00; ;42,00; ;19,00; ;26,00; ;28,00; ;6,00; ;70,00; ;61,00; ;322,50; 12-01-2025;11:00;37,90; ;18,40; ;31,00; ;43,00; ;21,00; ;25,00; ;30,00; ;6,00; ;72,00; ;62,00; ;327,90; 12-01-2025;12:00;38,60; ;18,80; ;32,00; ;44,00; ;19,00; ;26,00; ;30,00; ;7,00; ;73,00; ;61,00; ;330,60; 12-01-2025;13:00;37,90; ;18,70; ;32,00; ;42,00; ;20,00; ;27,00; ;28,00; ;6,00; ;71,00; ;61,00; ;324,90; 12-01-2025;14:00;36,80; ;18,70; ;31,00; ;43,00; ;19,00; ;25,00; ;28,00; ;5,00; ;72,00; ;60,00; ;319,80; 12-01-2025;15:00;38,80; ;18,70; ;33,00; ;42,00; ;20,00; ;27,00; ;29,00; ;7,00; ;72,00; ;63,00; ;331,80; 12-01-2025;16:00;38,80; ;18,70; ;31,00; ;43,00; ;19,00; ;25,00; ;29,00; ;6,00; ;72,00; ;60,00; ;323,80; 12-01-2025;17:00;37,60; ;18,60; ;32,00; ;42,00; ;21,00; ;27,00; ;28,00; ;6,00; ;72,00; ;62,00; ;327,60; 12-01-2025;18:00;38,30; ;18,50; ;32,00; ;43,00; ;20,00; ;25,00; ;30,00; ;6,00; ;71,00; ;62,00; ;327,30; 12-01-2025;19:00;38,10; ;19,00; ;32,00; ;44,00; ;19,00; ;26,00; ;30,00; ;7,00; ;73,00; ;61,00; ;330,10; 12-01-2025;20:00;40,00; ;21,20; ;32,00; ;42,00; ;19,00; ;27,00; ;30,00; ;6,00; ;72,00; ;63,00; ;331,00; 12-01-2025;21:00;65,20; ;46,70; ;46,00; ;54,00; ;21,00; ;57,00; ;28,00; ;10,00; ;179,00; ;114,00; ;574,20; 12-01-2025;22:00;120,80; ;148,10; ;62,00; ;130,00; ;19,00; ;125,00; ;41,00; ;18,00; ;220,00; ;123,00; ;858,80; 12-01-2025;23:00;131,50; ;152,10; ;77,00; ;162,00; ;20,00; ;141,00; ;42,00; ;18,00; ;230,00; ;128,00; ;949,50; 13-01-2025;00:00;131,30; ;73,10; ;115,00; ;171,00; ;20,00; ;161,00; ;49,00; ;25,00; ;236,00; ;126,00; ;1034,30; 13-01-2025;01:00;132,80; ;151,80; ;115,00; ;178,00; ;19,00; ;151,00; ;49,00; ;24,00; ;234,00; ;127,00; ;1029,80; 13-01-2025;02:00;131,30; ;120,90; ;120,00; ;173,00; ;21,00; ;156,00; ;48,00; ;26,00; ;233,00; ;126,00; ;1034,30; 13-01-2025;03:00;119,30; ;150,80; ;115,00; ;171,00; ;19,00; ;160,00; ;46,00; ;26,00; ;233,00; ;126,00; ;1015,30; 13-01-2025;04:00;131,70; ;149,10; ;112,00; ;174,00; ;20,00; ;155,00; ;46,00; ;26,00; ;231,00; ;127,00; ;1022,70; 13-01-2025;05:00;136,30; ;151,00; ;112,00; ;172,00; ;19,00; ;156,00; ;73,00; ;27,00; ;229,00; ;125,00; ;1049,30; 13-01-2025;06:00;121,50; ;152,80; ;118,00; ;178,00; ;21,00; ;157,00; ;78,00; ;24,00; ;235,00; ;128,00; ;1060,50; 13-01-2025;07:00;123,40; ;158,70; ;120,00; ;184,00; ;19,00; ;157,00; ;83,00; ;25,00; ;236,00; ;132,00; ;1079,40; 13-01-2025;08:00;134,50; ;156,90; ;119,00; ;183,00; ;19,00; ;159,00; ;79,00; ;24,00; ;239,00; ;134,00; ;1090,50; 13-01-2025;09:00;135,30; ;158,70; ;120,00; ;185,00; ;21,00; ;154,00; ;80,00; ;25,00; ;234,00; ;138,00; ;1092,30; 13-01-2025;10:00;124,30; ;156,80; ;109,00; ;174,00; ;19,00; ;142,00; ;79,00; ;23,00; ;239,00; ;133,00; ;1042,30; 13-01-2025;11:00;113,90; ;155,00; ;115,00; ;185,00; ;26,00; ;160,00; ;73,00; ;22,00; ;216,00; ;131,00; ;1041,90; 13-01-2025;12:00;140,20; ;153,60; ;119,00; ;179,00; ;24,00; ;138,00; ;55,00; ;26,00; ;180,00; ;132,00; ;993,20; 13-01-2025;13:00;131,90; ;153,00; ;118,00; ;178,00; ;25,00; ;133,00; ;52,00; ;25,00; ;178,00; ;141,00; ;981,90; 13-01-2025;14:00;130,20; ;151,80; ;118,00; ;172,00; ;23,00; ;138,00; ;49,00; ;24,00; ;183,00; ;130,00; ;967,20; 13-01-2025;15:00;134,40; ;150,10; ;118,00; ;183,00; ;24,00; ;155,00; ;52,00; ;24,00; ;180,00; ;78,00; ;948,40; 13-01-2025;16:00;135,20; ;152,60; ;119,00; ;180,00; ;25,00; ;158,00; ;51,00; ;24,00; ;175,00; ;96,00; ;963,20; 13-01-2025;17:00;135,90; ;149,90; ;116,00; ;180,00; ;24,00; ;123,00; ;51,00; ;24,00; ;181,00; ;131,00; ;965,90; 13-01-2025;18:00;136,60; ;140,00; ;116,00; ;184,00; ;26,00; ;52,00; ;55,00; ;25,00; ;177,00; ;133,00; ;904,60; 13-01-2025;19:00;137,30; ;149,20; ;112,00; ;176,00; ;24,00; ;41,00; ;53,00; ;23,00; ;181,00; ;132,00; ;879,30; 13-01-2025;20:00;137,10; ;131,70; ;99,00; ;185,00; ;24,00; ;38,00; ;53,00; ;17,00; ;181,00; ;132,00; ;866,10; 13-01-2025;21:00;136,40; ;140,80; ;52,00; ;182,00; ;25,00; ;42,00; ;52,00; ;9,00; ;188,00; ;130,00; ;816,40; 13-01-2025;22:00;119,50; ;108,30; ;38,00; ;174,00; ;24,00; ;45,00; ;53,00; ;3,00; ;211,00; ;131,00; ;798,50; 13-01-2025;23:00;134,60; ;161,00; ;38,00; ;169,00; ;24,00; ;47,00; ;50,00; ;3,00; ;227,00; ;131,00; ;823,60;

when i connect and try to connect from the script console, the gateway disconnect after 20/30 seconds and i get the thread below.

Thread [webserver-6506734] id=6506734, (TIMED\_WAITING for java.util.concurrent.SynchronousQueue$TransferStack@2ae6330b)  
java.base@17.0.10/jdk.internal.misc.Unsafe.park(Native Method)  
java.base@17.0.10/java.util.concurrent.locks.LockSupport.parkNanos(Unknown Source)  
java.base@17.0.10/java.util.concurrent.SynchronousQueue$TransferStack.transfer(Unknown Source)  
java.base@17.0.10/java.util.concurrent.SynchronousQueue.poll(Unknown Source)  
app//org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.reservedWait(ReservedThreadExecutor.java:325)  
app//org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:401)  
app//org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:969)  
app//org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1194)  
app//org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1149)  
java.base@17.0.10/java.lang.Thread.run(Unknown Source)

---

<div class="post-metadata">

**Author:** ![freggianini](https://avatars.discourse-cdn.com/v4/letter/f/e95f7d/32.png) [@freggianini](https://forum.inductiveautomation.com/u/freggianini)\
**Post date:** [May 22, 2025, 12:23pm UTC](https://forum.inductiveautomation.com/t/api-connection-error-via-scheduled-event-script/104720/4 "2025-05-22T12:23:09Z")

</div>

i have also this error

```python
14:11:15.558 [DesignerExecEngine-3] WARN com.inductiveautomation.ignition.client.gateway_interface.GatewayConnectionManager -- Connection to Gateway lost, due to exception.
com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Connessione interrotta dal software del computer host
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.newGatewayException(GatewayInterface.java:360)
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.getResponse(GatewayInterface.java:556)
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendMessage(GatewayInterface.java:292)
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendMessage(GatewayInterface.java:287)
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.invoke(GatewayInterface.java:967)
	at com.inductiveautomation.ignition.client.tags.impl.ClientTagSubscriptionManager.syncSubscriptions(ClientTagSubscriptionManager.java:331)
	at com.inductiveautomation.ignition.common.execution.impl.BasicExecutionEngine$TrackedTask.run(BasicExecutionEngine.java:593)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.runAndReset(Unknown Source)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.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: java.net.SocketException: Connessione interrotta dal software del computer host
	at java.base/sun.nio.ch.NioSocketImpl.implRead(Unknown Source)
	at java.base/sun.nio.ch.NioSocketImpl.read(Unknown Source)
	at java.base/sun.nio.ch.NioSocketImpl$1.read(Unknown Source)
	at java.base/java.net.Socket$SocketInputStream.read(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketInputRecord.read(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketInputRecord.readHeader(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketImpl.readApplicationRecord(Unknown Source)
	at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(Unknown Source)
	at java.base/java.io.BufferedInputStream.fill(Unknown Source)
	at java.base/java.io.BufferedInputStream.read1(Unknown Source)
	at java.base/java.io.BufferedInputStream.read(Unknown Source)
	at java.base/sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
	at java.base/sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
	at java.base/sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
	at java.base/java.net.HttpURLConnection.getResponseCode(Unknown Source)
	at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.getResponse(GatewayInterface.java:450)
	... 11 common frames omittedtype or paste code here

```

---

<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:** [May 22, 2025, 3:20pm UTC](https://forum.inductiveautomation.com/t/api-connection-error-via-scheduled-event-script/104720/5 "2025-05-22T15:20:39Z")

</div>

```python
An established connection was aborted by the software in your host machine

```

Something on your network (IT provided "security" software, most likely) is interrupting the connection. Not an Ignition issue.
