Read timed out but only when using Vision

Currently, I am able to run the following in Perspective using a change script of a label that is updated by a PLC tag:

collect = system.db.runNamedQuery("Collect",{"CollectId": collectId})

When I attempt to run the same thing in a propertyChange Script Editor of a label in Vision I receive the following error and I'm not sure what I need to do differently; does anyone have any tips on what may be the issue?

Traceback (most recent call last):
  File "<event:propertyChange>", line 23, in <module>
com.inductiveautomation.ignition.client.gateway_interface.GatewayException: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Read timed out

	caused by GatewayException: Read timed out
	caused by SocketTimeoutException: Read timed out

Ignition v8.1.32 
Java: Azul Systems, Inc. 11.0.18

Vision has a hard 60-second time limit on remote procedure calls to the gateway. Any query that takes longer will fail.

(That is an astonishingly slow query to run from a user interface.)

What do you recommend as an alternative?

If you absolutely have to tolerate unusually long queries, a workable (not simple) approach would be:

  • Use system.util.sendRequest() to ask a gateway message handler to start the query in an asynchronous task. Have it immediately return a unique token for the task.

  • In the asynchronous task, when complete, use system.util.sendMessage() to deliver the query result to the origin client ID, with the token in the payload, too.

  • In the client, place the token and some followup task information in a library script top-level dictionary. Perhaps with a timeout value.

  • Define a client message handler to receive completed queries, popping the tokens from the dictionary, and performing the follow-up task.

  • Define a client timer event to occasionally loop through the dictionary, checking and handling timeouts.

I recommend figuring out how to make that query reliably return results in a couple seconds.

3 Likes

Thank you. I will look into what you suggested.