locka99 / opcua

A client and server implementation of the OPC UA specification written in Rust
Mozilla Public License 2.0
476 stars 129 forks source link

[#189]: Fix detecting of failed connection #196

Open ctron opened 2 years ago

ctron commented 2 years ago

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] and Handle::spawn_blocking for the synchronous functions, but might involve some more work in other scenarios.

fixes #189

ctron commented 2 years ago

Unfortunately there was no "0.10" branch, so this PR failed to merge with master.

svanharmelen commented 2 years ago

@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)