Error on system.util.sendRequest. No response ever received

I am getting an error when trying to make a system.util.sendRequest call to a message handler on my gateway.

the sendRequest call is in a custom method called refreshData defined on a power table. The relevant parts of the function are bellow

def refreshData(self):


    resultData = None
	print 'Make Request'
		resultData = system.util.sendRequest('SPC_Config', 'GetSampleDataReportData', payload) #, timeoutSec = 600)
		print 'Request Failure'
	print 'Request Done'


I am calling this function using an invokeAsynchronous call. See an example of the call bellow

system.util.invokeAsynchronous(event.source.parent.parent.getComponent('Sample Data Table').refreshData)

The message handler on the gateway calls a function in a script file that queries the database and does some tranforms on the data. It is returning a python dict containing pyDataSets. Bellow is the relevant code from the script.

def getReportData():
	chartData = system.db.runPrepQuery(chartQuery, parameterList, "db_name")

	tableData = system.db.runPrepQuery(tableQuery, parameterList, "db_name")

	returnData = {
		'chartData': chartData,
		'tableData': tableData

	return returnData

The code in the gateway message handler that calls the function above and returns the results is bellow

reportData = project.sampleDataReport.getReportData()

return reportData

I can see when viewing log data from my scripts and the debug/trace messages from the MassageHandlerRunnable log that everything is working correctly on the gateway. Bellow are relevant log entries for MessageHandlerRunnable. You can see where it gets the results from the getReportData function which are exopected to be empty. It then converts the data to a java object and appears to attempt to send back the result.

|MessageHandlerRunnable|11Oct2021 11:36:36|Send message to Result Handler with: {‘tableData’: [ ], ‘chartData’: [ ]}|
|MessageHandlerRunnable|11Oct2021 11:36:36|Converting python result to java object|
|MessageHandlerRunnable|11Oct2021 11:36:36|Python function ran. Result: {‘tableData’: [ ], ‘chartData’: [ ]}|
|MessageHandlerRunnable|11Oct2021 11:36:34|Valid runnable Python function found|

However on the client nothing seems to be returned. The client waits for some time and eventually an exception is thrown. The exception is bellow. It appears to show that the call failed and no result was ever reveived.

11:37:34.287 [Thread-73] ERROR client.scripting.SystemUtilities - Error invoking sendRequest from client.
com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Results for asynchronous rpc call were not received within the specified amount of time [60000 ms] for task ‘355707ef-d109-4a0f-bd88-42d7ed64aa01’
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.newGatewayException(
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendMessage(
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendMessage(
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.invoke(
at com.inductiveautomation.ignition.client.script.DesignerSystemUtilities$SendRequestManager.invokeRequest(
at com.inductiveautomation.ignition.client.script.DesignerSystemUtilities.sendRequestInternal(
at com.inductiveautomation.ignition.common.script.builtin.SystemUtilities.sendRequestInternal(
at com.inductiveautomation.ignition.common.script.builtin.SystemUtilities.sendRequest(
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at com.inductiveautomation.ignition.common.script.ScriptManager$
at org.python.pycode.pyx86.refreshData$1(:96)
at org.python.pycode.pyx86.call_function()
at org.python.core.PyMethod.instancemethod___call
at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(
at com.inductiveautomation.ignition.client.script.DesignerSystemUtilities.lambda$_invokeAsyncImpl$1(
at java.base/ Source)
Caused by: java.util.concurrent.TimeoutException: Results for asynchronous rpc call were not received within the specified amount of time [60000 ms] for task ‘355707ef-d109-4a0f-bd88-42d7ed64aa01’
at com.inductiveautomation.ignition.client.util.gui.progress.ClientProgressManager$RunningTask.waitForResult(
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendMessage(
… 26 common frames omitted

I am wondering if anyone else has seen things like this. Also I see nothing in the docs but are there limitations as to what data can be returned to sendRequest calls?

I would not expect this to work. You can’t safely use components’ properties or methods in background threads. (“Use” == read or write.) That you are losing something is the least bad thing that can happen (up to and including complete client lockup). Also, print is not likely to work in a background thread (though it sometimes does). Use a logger instead.

Review this topic, then report back if you still have problems while following Swing’s rules:

1 Like

Thanks for the info. I changed the call to the component method so that I am no longer doing background processing. I am just calling the bellow function directly.

event.source.parent.parent.getComponent(‘Sample Data Table’).refreshData()

The problem is still happening. I see in exception that it is still referring to “asynchronous rpc call.” As far as I know I have not explicit async calls in the process anymore. Is the sendRequest function intrinsically async and causing the issue still?

Yes. Running queries and reading/writing tags with scripting also involve gateway round trips. You probably need a background thread, but you need to use invokeLater to pass the results back into the UI.

So I think this issue is unrelated to running the sendRequest in any gui thread. It fails the same way when just simply calling the sendRequest method from the script console.

I would expect as much because your error is - Results for asynchronous rpc call were not received within the specified amount of time [60000 ms], no matter what context you are calling it from your gateay script is taking too long to return a result.

You can change that by doing system.util.sendRequest(..., timeoutSec=120) to lengthen the timeout time to 120 seconds (or whatever you want it to be), or you can try optimizing your gateway script, but right here is the cause.

chartData = system.db.runPrepQuery(chartQuery, parameterList, "db_name")

tableData = system.db.runPrepQuery(tableQuery, parameterList, "db_name")

How fast do these queries run in a vacuum? If its taking over 60 seconds to get a response and these two queries are all you are doing, I suspect you could probably optimize your tables a bit via indexing or other means.

That is the thing. It doesn’t appear to be due to any delay in the server side queries. I have logging on the gateway script. The function is returning the data in < 2 seconds

In your getReportData(): do you do any custom logging so that you can verify it’s actually running? Something is going on. Do you see any issues in your logs? Perhaps a typo in the message handler name.

Yes I do. Here are the log messages. I expect the datasets to be empty so that is not an issue.

I sorted them first to last in time order. The returnData message is right before the return statement in the function.

Logger	        Time	            Message
getReportData	09Nov2021 10:34:51	parameterList: [False, 'BK1 Lining', 'All Tests', 'All Work Orders', 'All Case Numbers', 'All Batch Numbers', 'All Shifts', 'All Drawing Numbers', '20211005', '20211012']
getReportData	09Nov2021 10:34:51	Chart Results: <PyDataset rows:0 cols:6>
getReportData	09Nov2021 10:34:51	Chart X Value:
getReportData	09Nov2021 10:34:51	No data in chart
getReportData	09Nov2021 10:34:51	selectedPlotSampleTakenDatetime:
getReportData	09Nov2021 10:34:51	[False, 'BK1 Lining', 'All Tests', 'All Work Orders', 'All Case Numbers', 'All Batch Numbers', 'All Shifts', 'All Drawing Numbers', '20211005', '20211012', '']
getReportData	09Nov2021 10:34:52	Table Results<PyDataset rows:0 cols:22>
getReportData	09Nov2021 10:34:52	chartData: <PyDataset rows:0 cols:6>
getReportData	09Nov2021 10:34:52	tableData: <PyDataset rows:0 cols:22>
getReportData	09Nov2021 10:34:52	returnData: {'tableData': [], 'chartData': []}```

Your best bet might be to call IA at this point then. Seems like it is trying to return it but your client is just not getting it for some reason that the logs are not showing.

Thanks. That’s what I’ll do