FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
07-16-2024 02:00 PM
I am currently working on an app that should be able to do the following:
It should be able to store data over a user-selected period of time.
- You need to specify the node you want to save.
- You need to specify the mount point of the USB device.
- The period you want (in seconds).
- And the interval at which a value should be saved during that period.
So far, it works quite well, however, I keep getting the following error message in the node:
Method failed - Error: 408
DL_TIMEOUT
original error: DL_TIMEOUT
and
Method failed - Error: 400
DL_TYPE_MISMATCH
Can't read type Information
Despite the error messages, the saving function works, but then the app crashes and has to be restarted.
My specific question is how I can increase the timeout and why I am getting a mismatch error.
Below you will find the important files.
And a few screenshots of what I have already tried:
here you can see the mismatch error
timeout error
but if i chose 2 seconds for period it works
I guees the reason is in node: types/webserver/settings
the default is at 3000 ms, is there a possibilty to change the default?
i also tried to change the value in callable-timeout settings
In the logbook you can see that my code works in manipulating the timeout; it says: Timeout value for the method sdk/usb/history successfully changed at 24000 ms
I tried to set the timeout based on the period and interval
and finally you can see that it somehow worked
Maybe someone with similar problems could help me out.
Thanks in advance
Solved! Go to Solution.
07-16-2024 03:18 PM
@TY14 ,
It seems that the type mismatch error only happens when you save certain datalayer nodes? There is a lot of casting happening here, so it could very well be those operations.
if "history" in address:
root = InertialValue3.GetRootAs(buffer, 0)
try:
node = root.Node()
mount = root.Mount()
period = root.Period()
interval = root.Interval()
if isinstance(node, bytes):
node = node.decode('utf-8')
if isinstance(mount, bytes):
mount = mount.decode('utf-8')
# Sicherstellen, dass period und interval Ganzzahlen sind
if not isinstance(period, int):
period = int(period)
if not isinstance(interval, int):
interval = int(interval)
# Timeout-Wert berechnen
timeout_value = 1000 * period * interval
# Setzen des Timeouts für die Methode
result = self._provider.set_timeout_node(self._providerNode, timeout_value)
if result == Result.OK:
print(f"Timeout-Wert für Methode {self._nodeAddress} erfolgreich auf {timeout_value} ms gesetzt")
else:
print(f"Fehler beim Setzen des Timeout-Werts für Methode {self._nodeAddress}: {result}")
cb(Result.FAILED, None)
return
except (ValueError, TypeError) as e:
print(f"Error while decoding values: {e}", flush=True)
cb(Result.TYPE_MISMATCH, None)
return
I don't have a good guess on the DL_TIMEOUT problem besides overflowing some type maximum.
I would suggest deploying this app with a remote target and debugging. Set breakpoints on the TYPE_MISMATCH and DL_TIMEOUT errors to catch them as they are thrown.
07-19-2024 09:46 AM
All right, thanks for the input.
I thought it might be the casting, but when I take it out I get a fatal error
08-01-2024 08:16 AM
@TY14 ,
I think your problem is that you're answering the request in an synchronous way blocking the provider. So the provider can't send keepalives back to the broker/client. When a client gets no keepalive or answer after 3 seconds it will asume that the request is dead and return a timeout.
A solution is to do it in an asynchronous way:
So the provider thread is not blocked and can send keepalives back to the client/webserver. You as a implementer of a provider can modify the timeout values:
08-05-2024 04:28 PM
Thanks for the comprehensive explanation.
But I somehow figured out how to increase the timeout value in the data layer