# Slow socket open

**URL:** <https://forum.inductiveautomation.com/t/slow-socket-open/24032>\
**Category:** Ignition\
**Tags:** ignition79, scripting\
**Created:** [April 11, 2019, 10:06am UTC](https://forum.inductiveautomation.com/t/slow-socket-open/24032 "2019-04-11T10:06:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmaynes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmaynes/32/6852_2.png) [@cmaynes](https://forum.inductiveautomation.com/u/cmaynes)\
**Post date:** [April 11, 2019, 10:06am UTC](https://forum.inductiveautomation.com/t/slow-socket-open/24032/1 "2019-04-11T10:06:10Z")

</div>

When using the python socket lib, it is slow to open the socket -4.5 seconds. If I try in just a terminal in python and not jython on Windows, it takes about 1 sec. Does anyone else have this issue and does anyone have a workaround beyond just trying to keep the socket open forever?

---

<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:** [April 11, 2019, 11:57am UTC](https://forum.inductiveautomation.com/t/slow-socket-open/24032/2 "2019-04-11T11:57:23Z")

</div>

One workaround would be to use the Java socket API instead.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 11, 2019, 12:00pm UTC](https://forum.inductiveautomation.com/t/slow-socket-open/24032/3 "2019-04-11T12:00:35Z")

</div>

> [@cmaynes](#):
>
> trying to keep the socket open forever?

It requires some care handling scripting object lifetimes, but this is what I do. And I use the Java libraries as Kevin suggests, not python.

---

<div class="post-metadata">

**Author:** ![cmaynes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmaynes/32/6852_2.png) [@cmaynes](https://forum.inductiveautomation.com/u/cmaynes)\
**Post date:** [April 11, 2019, 12:56pm UTC](https://forum.inductiveautomation.com/t/slow-socket-open/24032/4 "2019-04-11T12:56:19Z")

</div>

You are right! … there is something very wrong with jython’s version of the python socket lib.

~4.5 seconds to connect using python’s **socket**  
~0.003 seconds to connect using **java.net.Socket**

I will use java, but that is kinda a bummer that python is so inefficient here.
