ScriptExporter limitations?

I’m using the ScriptExporter to send a command then get the response of that command.
I do this every 1 second to monitor the latest status of the peripheral attached to the robot.
But after some time, the polyscope freezes. Further debugging puts this between 250~350 seconds.

After a lot of debugging, I found it stops at the Socket returnSocket = server.accept(); line in the readValueFromRobot function of ScriptExporter.
I tried fixing it by adding server.setSoTimeout(2000); right before the accept().
This only prevented polyscope from freezing. After it triggers the timeout, it still does not get the response from the robot.

The command I send using ScriptExporter is as follows:
socket_open(peripheral IP, peripheral port)
socket_send_byte(x) ← multiple lines depending on command and data
socket_read_byte_list(30)
socket_close()

I’m thinking this is more a ServerSocket issue and less a ScriptExporter issue but I know little of either to draw a conclusion.
Anyone have any knowledge about this?

Thanks in advance.

The script exporter classes are just really laggy, and if sent rapidly, will completely freeze the robot for a time like you’re seeing. I’ve not found any way to avoid this. If you figure something out, please let me know.

Thanks for your reply, @eric.feldmann.

So far I haven’t found a fix for this.
A workaround I’m considering is, instead of reading every second, I would just read on demand.

That is, instead of reading the position of the attachment every second, I would read the position after every movement to get it’s current position.