Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling of StatusBadSessionNotActivated #655

Open
bitomaxsp opened this issue May 27, 2023 · 3 comments
Open

Handling of StatusBadSessionNotActivated #655

bitomaxsp opened this issue May 27, 2023 · 3 comments

Comments

@bitomaxsp
Copy link
Contributor

While dealing with non quite stable PLCs I noticed that sometimes in response to any request PLC can answer with StatusBadSessionNotActivated. After quite a lot of debugging, reading the standard and the code, I figured, that library doesn't have a bug with sessions activation. But @magiconair brought my attention to the fact the Client has public API to control different aspects of session creation: CreateSessionWithContext and ActivateSessionWithContext. Yes, this makes library extremely robust, but on the other hand, it probably make sense then to add StatusBadSessionNotActivated handling to that switch (https://github.com/gopcua/opcua/blob/main/client.go#L297) and do restoreSession action.

The other option, probably more cleaner, will be to make session API private, since then Client will correctly handle session as is it now.

This issue is to discuss preferred approach going forward.

@bitomaxsp
Copy link
Contributor Author

@kung-foo

@magiconair
Copy link
Member

Is there any use-case where clients would need to create/activate sessions manually? This is all handled in the client and the client also has the monitor loop without nothing really works. We will break the API with v0.5 anyway so we could do this then.

@magiconair
Copy link
Member

There is the crypto example which uses ActivateSession and DeactivateSession to move a session between client connections. It feels a bit contrived but maybe there is the use-case that you connect on one address, establish the session, and then move that session to another connection.

https://github.com/gopcua/opcua/blob/v0.3.15/examples/crypto/crypto.go#L82-L97

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants