Reputation: 51
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
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
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