Marcello
Marcello

Reputation: 51

Python freeopcua server: how to know number of connected clients?

I have successfully set-up a freeopcua server and it communicates well with clients but now I would like to know how many clients are connected to my server. Is there a method or workaround to know how many clients are connected to a freeopcua server?

Upvotes: 1

Views: 653

Answers (1)

araisch
araisch

Reputation: 1940

For OPC UA it should be in Server/ServerDiagnostics/ServerDiagnosticsSummary/CurrentSessionCount

But afaik there is absolutely no code included about all this Diagnostics-Stuff neither in python-opcua nor in opcua-asyncio.

A workaround would be to implement it and pull request.. haha

You can check for established connections, something like netstat -anp | grep :4840 | grep ESTABLISHED | wc -l. In Py3 you could do something similar with psutil.net_connections() and also filter for Port and ESTABLISHED. Docs

EDIT: Win 10

netstat -a -o -n -b | findstr 4840 | findstr ESTABLISHED

Btw. the Established thing is localized in Windows.. so maybe must be replaced.

So if all Clients share the same IP it is a little bit harder if they open multiple sockets each due to the fact you can't sort out connections from same source IP. If they do so imho the only option is to implement the ServerDiagnostics stuff in the lib.

Upvotes: 1

Related Questions