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

added is_connected() method & PEP-8 asyncua/client/client.py #157

Conversation

luisfmelo
Copy link
Contributor

Close #155

Changes:

  • added is_connected() method
  • PEP-8 asyncua/client/client.py

"""
Get OPC-UA client connection status.
"""
return self.uaclient.protocol.state == UASocketProtocol.OPEN
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might work... but does it always work? I man can't we get errors like "protocol has not attrtbute called state",etc...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also tried this in my own local implementation of is_connected and had trouble getting it to be robust. For example, if I disconnected network, the connection_lost callback didn't necessarily get called immediately, and the state still remained OPEN. I settled on querying the status node of the server as it seemed to be the most reliable method, but would be interested in trying to get this method to be robust.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also from what I remember looking at how prosys and unified automation clients work. They seem to be polling at quite high frequency. Reading the server node once a second or similar. So this seems to be the common way to do it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we call get_namespaces()? I know that it is not the cleanest way to do it but it is an option

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not reading the server state node? If this is what all others do.. Then you can also check what is the state of server

oroulet pushed a commit that referenced this pull request Mar 22, 2020
@oroulet oroulet closed this Jul 24, 2020
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

Successfully merging this pull request may close these issues.

How can I know if the connection is still active?
3 participants