Failed to create a child event loop

Dears
I have “gateway start up” script which listing to port 31001 , it works well.
when i active telent script in port 23 , the startup scrip get the below error.

java.base/java.lang.reflect.Constructor.newInstance(Unknown Source) at org.python.core.PyReflectedConstructor.constructProxy(PyReflectedConstructor.java:211) java.lang.IllegalStateException: java.lang.IllegalStateException: failed to create a child event loop

Could you please help me about this issue.

Best Regards

Are you listening to a port directly in your event script? That ties up a thread of the gateway’s event handling thread pool. Anyways, show your code.

Kindly find script below

import socket
host = ‘192.168.1.1’
port=31001

while True:
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((host, port))
s.listen(5)
conn , addr =s.accept()
system.tag.write("[default]addr",addr)
while True:
data = conn.recv(512)
if not data :
s.close()
break
else:
system.tag.write("[default]data",data)
conn.sendall(“ok”.encode())
s.close()
except:
print (“TCP Listining Stopped”)

Please edit your post to include code markers. Use three backquotes above and below your code, so it looks like this in the editor:

```
pasted code
```

That said, you can’t loop forever in any event script. You must use system.util.invokeAsynchronous() to launch a separate thread.

Thanks for your help, i created script in project library with while loop to listen to specific port , and called it with system.util.invokeAsynchronous() in start up script , it worked well for a day then hanged , if i restart gateway ,it works again.

could you please help me about he best choice of running the script witch listen forever to specific port>

Best Regards