OPCFoundation / UA-.NETStandard

OPC Unified Architecture .NET Standard
Other
1.89k stars 926 forks source link

When an exception occurs, the connection to the server should be reestablished? #2569

Closed caradilin closed 3 months ago

caradilin commented 3 months ago

Type of issue

Current Behavior

My Opcua server is currently built using LabView, and during testing, I have found that ServiceResultException type exceptions are often occasionally caught.

The following types of StatusCodes are high-frequency types: BadConnectionClosed, BadResourceUnavailable, BadSecureChannelClosed,BadSessionIdInvalid,BadNotConnected.

Should I re-establish the connection with the server in the above situation?

The following is a log that records the OpcUa client:

2024 -03-28.Opc.Ua.8888.log

Captured Error at 17:20:40.5051 Ua. ServiceResultException: BadConnectionClosed.

Captured Error at 17:33:04.4723 Ua. ServiceResultException: Error establishing a connection: BadNotConnected.

Captured Error at 17:36:00:4999 Ua. ServiceResultException: BadSecureChannelClosed.

Unfortunately, I am unable to obtain the logs recorded by the server. Please help me analyze the above issue.

Expected Behavior

No response

Steps To Reproduce

No response

Environment

- OS:
- Environment:
- Runtime:
- Nuget Version:
- Component:
- Server:
- Client:

Anything else?

No response

mregen commented 3 months ago

Hi @caradilin , please see the sample here how to reestablish a connection on error: https://github.com/OPCFoundation/UA-.NETStandard/blob/master/Applications/ConsoleReferenceClient/UAClient.cs