Quantcast
Viewing all articles
Browse latest Browse all 1794

Reconnecting after server close connecion - by: bmts

Hello
I have a problem with reconnecting. I use in my .Net application construction like this:

ObjectDataPathAsString = "[ObjectsFolder]/" + PlcName + PartialObjectPath; //

OpcUaBrowsePath = OpcLabs.EasyOpc.UA.Navigation.UABrowsePath.Parse(ObjectDataPathAsString, "www.siemens.com/simatic-s7-opcua");

this.OpcMapper.Map(OpcObject, new UAMappingContext()
{
EndpointDescriptor = EndpointDescriptor, // the OPC server

NodeDescriptor = new UANodeDescriptor // complex node
{
BrowsePath = OpcUaBrowsePath
},
MonitoringParameters = this.ReadUpdateTime, // requested sampling interval

});


if (CallBackMethodRef != null)
{
OpcMapper.SubscribeTarget(iSubscribe, this.OpcObject, ObjectDataPathAsString, false);
ObjectChangedHandle = OpcMapper.Client.SubscribeDataChange(EndpointDescriptor, OpcUaBrowsePath, ReadUpdateTime, CallBackMethodRef);
}


After success subscription and any opperation on OPC-UA server side the server close the connection and i get exception:

OPC-UA service result - An error specific to OPC-UA service occurred.
---- SERVICE RESULT ----
StatusCode: {BadSecureChannelClosed} = 0x80860000 (2156265472)
Description: BadSecureChannelClosed
AdditionalInfo: >>> BadSecureChannelClosed
--- at Opc.Ua.Bindings.TcpAsyncOperation`1.End(Int32 timeout)
--- at Opc.Ua.Bindings.TcpClientChannel.EndSendRequest(IAsyncResult result)
--- at Opc.Ua.SessionClient.EndPublish(IAsyncResult result, UInt32& subscriptionId, UInt32Collection& availableSequenceNumbers, Boolean& moreNotifications, NotificationMessage& notificationMessage, StatusCodeCollection& results, DiagnosticInfoCollection& diagnosticInfos)
--- at Opc.Ua.Client.Session.OnPublishComplete(IAsyncResult result)
StatusCode: {BadTcpInternalError} = 0x80820000 (2156003328)
Description: An existing connection was forcibly closed by the remote host
StatusCode: {Bad} = 0x80000000 (2147483648)
Description: An existing connection was forcibly closed by the remote host
AdditionalInfo: >>> An existing connection was forcibly closed by the remote host
--- at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
--- at Opc.Ua.Bindings.TcpMessageSocket.DoReadComplete(IAsyncResult result)
--- at Opc.Ua.Bindings.TcpMessageSocket.OnReadComplete(IAsyncResult result)
---- REMARKS ----
The server may have rejected the connection because it does not trust the client (e.g. certificate problem); check the diagnostics on the server side, if possible.

After this exception is called this Method on Mapper:

this.OpcMapper.Client.UnsubscribeAllMonitoredItems();

and after some time Is aggain called code above (map and subscribe) but it not works.

I Use .NET 4.6.2, Target x64.

What is correct way for recconecting? Or what is Wrong in my code?

Thanks for response.

Viewing all articles
Browse latest Browse all 1794

Trending Articles