gopcua / opcua

Native Go OPC-UA library
MIT License
857 stars 262 forks source link

Too many sessions #472

Open siscia opened 3 years ago

siscia commented 3 years ago

While keeping the number of connections to the OPCUA server constants, I keep seeing errors like:

10:45:23.460078 The server has reached its maximum number of sessions. StatusBadTooManySessions (0x80560000)
10:45:23.877245 The server has reached its maximum number of sessions. StatusBadTooManySessions (0x80560000)

This error is well managed in the code, but maybe it should be fixed at the library level.

It seems like when a OPCUA connection is disconnected, the session it is not closed immediately. Now, I am not sure if this is wanted, or not.

milgner commented 3 years ago

What server are you using? I just encountered the selfsame error with a different library where sessions were kept on the server even after the client disconnected.

siscia commented 3 years ago

I am mostly agains Siemens equipment, but I am not sure of the server details.

milgner commented 3 years ago

The problem usually only occurs if the client doesn't send a CloseSession request. Check your code: it should have defer client.Close() right after establishing the connection or you will need to manually close it wherever appropriate.

29 Sep 2021 12:22:32 Simone Mosciatti @.***>:

I am mostly agains Siemens equipment, but I am not sure of the server details.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub[https://github.com/gopcua/opcua/issues/472#issuecomment-930046569], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AABHCGNEBMY3JRTVGHI6SP3UELSGPANCNFSM5E2AWWSA]. [data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAABCCAYAAADjVADoAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAAnSURBVHic7cEBDQAAAMKg909tDwcUAAAAAAAAAAAAAAAAAAAAAPBjRFIAASHKmKkAAAAASUVORK5CYII=###24x24:true###][Tracking image][https://github.com/notifications/beacon/AABHCGOJG7O2HAN3QCPSTWLUELSGPA5CNFSM5E2AWWSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOG5XWE2I.gif]

siscia commented 3 years ago

Thanks a lot!

We are already closing the session with a call to client.Close() which is indeed the reason why I opened the ticket.

milgner commented 3 years ago

In that case I am out of ideas. I encountered the same problem with another client/server combination but with this library everything works expected and the session is gone after closing the client.

29 Sep 2021 17:03:26 Simone Mosciatti @.***>:

Thanks a lot!

We are already closing the session with a call to client.Close() which is indeed the reason why I opened the ticket.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub[https://github.com/gopcua/opcua/issues/472#issuecomment-930262800], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AABHCGK5WEZN63RZWD2BGHLUEMTD3ANCNFSM5E2AWWSA]. [data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAABCCAYAAADjVADoAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAAnSURBVHic7cEBDQAAAMKg909tDwcUAAAAAAAAAAAAAAAAAAAAAPBjRFIAASHKmKkAAAAASUVORK5CYII=###24x24:true###][Tracking image][https://github.com/notifications/beacon/AABHCGKNOZBPV6MVVHGEIFDUEMTD3A5CNFSM5E2AWWSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOG5ZK6EA.gif]

fenogentov commented 2 years ago

close() does not close the channel and not reset the session