AndreasHeine / opcua-sub-to-websocket

OPC UA Server -> OPC UA Client / WebSocket Server -> WebSocket Client
13 stars 5 forks source link

Recoonection and creating new session #1

Closed ganesh1306 closed 4 years ago

ganesh1306 commented 4 years ago

i need only when the server disconnects it has to connect and continue other works and create a session in the client if serves is restart

with this statement

The preferred mechanism for a Client to monitor the connection status is through the keep-alive of the Subscription. A Client should subscribe for the State Variable in the ServerStatus to detect shutdown or other failure states. If no Subscription is created or the Server does not support Subscriptions, the connection can be monitored by periodically reading the State Variable.

Reconnection

When a Client loses the connection to the Server, the goal is to reconnect without losing information. To do this the Client shall re-establish the connection by creating a new SecureChannel and activating the Session with the Service ActivateSession. This assigns the new SecureChannel to the existing Session and allows the Client to reuse the Session and Subscriptions in the Server. To re-establish the SecureChannel and activate the Session, the Client shall use the same security policy, application instance certificate and the same user credential used to create the original SecureChannel. This will result in the Client receiving data and event Notifications without losing information provided the queues in the MonitoredItems do not overflow.

i tired with this i am able to get

AndreasHeine commented 4 years ago

i know these quotes from the opcua reference... they always discribe a unicorn one the one hand they say pub/sub is like fire and forget and on the other hand there should be no dataloss... if you subscribe to server state you only get notified if the server gracefully shutdown

in my opinion the easiest way is in the asyncua_client.py just read the service value cyclic and reconnect and resubscribe this catches all kinds of connection problems!

if you still want to use it like in the spec writen you need to use the low-level-api not the high-level-api which is made cover most importent features in easy to use fashion!

ganesh1306 commented 4 years ago

i agree with you using a asyncua_client.py but the sessions on the server side will increase still every time by using https://reference.opcfoundation.org/v104/Core/docs/Part4/6.7/ according to Figure 36 in the link, the session count will increase only when the connection loss happens according to me if am wrong correct me

AndreasHeine commented 4 years ago

dont understand your question!

do you mean that:

SessionTimeout

Sessions should not timeout very easily, so a timeout value of one hour is a good default value (the default also in UaClient). It is there just that the server can close sessions that have not been active (no message of any type from the client received for a longer period than SessionTimeout), because the client has died or is no longer connected to the server .

ganesh1306 commented 4 years ago

I am using prosys in that when I implemented the reconnection logic of client ,in prosys server under session section the value of session is limited to 50,

  1. One important question is how we will come to know that server is disconnected from client, after the disconnected
  2. I need to reconnect with server till their I nedd to check the whether server will available or not if available then connect

While do this implementation the session on the server side is increments in prosys.

AndreasHeine commented 4 years ago

i already anwered this question in another issue (python-opcua) or here !!! you should look in python-opcua issues your not the first one...