Maximum allowed clients

Questions regarding the use of the C++ SDK for Server or Client development or integration into customer products ...

Moderator: uasdkcpp

Post Reply
smnrock
Jr. Member
Jr. Member
Posts: 4
Joined: 10 Jan 2012, 10:46

Maximum allowed clients

Post by smnrock »

Hi there,

Is there way to set number of clients who can connect the UA server? for eg, i want to set only 5 clients can connect to my UA server.

Thanks

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re:Maximum allowed clients

Post by Support Team »

Hello smnrock,
the ServerConfig class provides the method getSessionSettings() to read the session parameters. One of these parameters is the MaxSessionCount. When the maximum count is reached the session manager will reject any further createSession call with the error code OpcUa_BadTooManySessions.
There are some subclasses of the ServerConfig class delivered with the SDK. One of them is the class ServerConfigXml that's used by the UaDemoServer. It's reading the xml file ServerConfig.xml.
In the begining of that file you can find a setting MaxSessionCount. By default that value is set to 100.

Best Regards,
Unified Automation Support Team
Best regards
Unified Automation Support Team

smnrock
Jr. Member
Jr. Member
Posts: 4
Joined: 10 Jan 2012, 10:46

Re:Maximum allowed clients

Post by smnrock »

Thanks for your support. I did test with MaxSessionCount, but the problem with this approach is, if some clients are disconnected abruptly, may be due to crash or system failure, then server is not allowing to reconnect again. Basically its not reducing the session count, it the client closed in a unexpected way.

Is there a way, this issue can be overridden?

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re:Maximum allowed clients

Post by Support Team »

Hello smnrock,
this is the intended behaviour resulting from the design of OPC UA.
Each session has an individual lifetime. Each session is kept in the server until the lifetime for that session has expired. If a client loses the connection it can reconnect and activate the session again. Like that you can make sure that a client that was connected can reconnect after a short network interruption.
You can configure the minimum and maximum session timeout in the ServerConfig.

Best Regards,
Unified Automation Support Team
Best regards
Unified Automation Support Team

smnrock
Jr. Member
Jr. Member
Posts: 4
Joined: 10 Jan 2012, 10:46

Re:Maximum allowed clients

Post by smnrock »

I can understand about the network interruption.. I've different scenario, which needs to be handled properly. Can you give any solution for this situation? Server is set to accept only one client by setting MaxSessionCount=1; Now the client is crashed and when we try to reconnect the client, we get error "BadTooManySessions". I understand this is the expected behaviour. Is there anyways i can force the server to accept the client, if there is no other client is connected? Even before session timeout occures?

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re:Maximum allowed clients

Post by Support Team »

Your Client should have following strategy: try to "activate" the old session again and reuse it as long as it hasn't timed out in the server. Only if activation fails the Client should create a new session. In order to do so your Client should persist the session information in order to activate it after it has crashed.

Alternatively your client could negotiate short session timeout with the server. After restart of your Client the session should be already timed out in the server, hence your client can create a new session.
Best regards
Unified Automation Support Team

smnrock
Jr. Member
Jr. Member
Posts: 4
Joined: 10 Jan 2012, 10:46

Re:Maximum allowed clients

Post by smnrock »

Thanks for your solutions. It looks like the first one, we might be interested in :)

Post Reply