locka99 / opcua

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

feat: use CloseSession request when disconnecting #138

Closed milgner closed 2 years ago

milgner commented 2 years ago

When using the library - excellent work, btw! :D - I noticed that the sessions would remain open in the OPC UA servers I was connecting to.

Since the current code was already deleting all subscriptions anyway, I decided to also add the CloseSession request.

One thing I'm not sure about is how to best test this - if you can give me a hint, I'll gladly do something about that.

milgner commented 2 years ago

Is there anything I should do to get this merged? Been using this version for about a week now and it works fine, removing the session from the server upon disconnect.

Not sure if there are plans to add session resumption for replacing old TCP connections? In that case, closing the session should probably be optional and instead be exposed through a separate method?

saabye-io commented 2 years ago

I have just merged this into master on on my own fork https://github.com/saabye-io/opcua and tested it with "OPC UA Server Simulation" from Integration Objects, which shows all sessions open sessions.

This PR works perfectly and sessions are gone when I disconnect.

We really need to be able to close the sessions as small PLCs does not always handle this well.

locka99 commented 2 years ago

Thanks I'll take it.