Open vrushalikatkade opened 1 year ago
@vrushalikatkade Sorry, currently the SDK has no support for such function.
@mregen thanks for reply, actually i have windows service for connecting opcua server. in this service , after starting the computer the service try to connect to the server ,but if server is unavailable , then this function throws exception . I want wait for server connection until server active i used following code log.writelog("2 - Discover endpoints of OPC UA server."); Uri endpointURI = new Uri(server.EndPointUrl); var endpointCollection = DiscoverEndpoints(config, endpointURI, 10); var selectedEndpoint = SelectUaTcpEndpoint(endpointCollection, certOK);
log.writelog("3 - Create a session with OPC UA server.");
var endpointConfiguration = EndpointConfiguration.Create(config);
var endpoint = new ConfiguredEndpoint(selectedEndpoint.Server, endpointConfiguration);
endpoint.Update(selectedEndpoint);
var session =await Opc.Ua.Client.Session.Create(config, endpoint, true, session1.Name, 60000, null, null); session.KeepAlive += Client_KeepAlive; session.TransferSubscriptionsOnReconnect = true;
@vrushalikatkade yes you can retry calling Session.Create, or you could retry calling SelectEndpoint which internally tries to reach the discovery endpoint until no timeout or exception occurs.
in Session.Create() function timeout set to 60000 but it will not wait for the server active within second through exception
exception:
Opc.Ua.ServiceResultException
HResult=0x80131500
Message=Error establishing a connection: BadNotConnected
Source=Opc.Ua.Core
StackTrace:
at Opc.Ua.Bindings.ChannelAsyncOperation`1.End(Int32 timeout, Boolean throwOnError)
at Opc.Ua.Bindings.UaSCUaBinaryClientChannel.EndSendRequest(IAsyncResult result)
at Opc.Ua.DiscoveryClient.GetEndpoints(RequestHeader requestHeader, String endpointUrl, StringCollection localeIds, StringCollection profileUris, EndpointDescriptionCollection& endpoints)
at Opc.Ua.DiscoveryClient.GetEndpoints(StringCollection profileUris)
at Opc.Ua.ConfiguredEndpoint.UpdateFromServer(Uri endpointUrl, ITransportWaitingConnection connection, MessageSecurityMode securityMode, String securityPolicyUri)
at Opc.Ua.ConfiguredEndpoint.UpdateFromServer()
at Opc.Ua.Client.Session.
In node opcua server connection ,the following function will retrying to connect opc ua server ,if it is not available. " client.on("backoff", () => console.log("retrying connection"));"
which function is used for retrying server connection in UA-.NETStandard. please mention the example