Open ctron opened 2 years ago
Unfortunately there was no "0.10" branch, so this PR failed to merge with master.
@ctron maybe you can checkout this branch: https://github.com/svanharmelen/opcua/tree/feature/async-client it's intended to become a full async-client. I did run and test it a little, but not enough yet to create a PR for it to this repo...
EDIT: I will create a draft PR to create awareness (#197)
The client failed to detect a broken connection, as it didn't react on a write error, aside from logging it.
This change makes it set the connection to finished when a write error occurs, which will trigger a re-connect.
However, due to the fact that in a single session actually two Tokio runtimes are involved, the session drops a Tokio runtime from an async context, which will panic.
In order to fix this, this PR also removes the explicit Tokio runtimes from the TCP comms and session struct. This means a breaking change, as now the client functions need to be called with an active Tokio context. This is easy as using
#[tokio::main]
andHandle::spawn_blocking
for the synchronous functions, but might involve some more work in other scenarios.fixes #189