diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 0000000..d9af2ea --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/opcplc.sln b/opcplc.sln index 856d7cd..40bb668 100644 --- a/opcplc.sln +++ b/opcplc.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.4.33205.214 @@ -40,6 +40,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "templates", "templates", "{ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "opc-plc-tests", "tests\opc-plc-tests.csproj", "{978DA9FC-4211-46CE-8548-D16E3DC3550F}" EndProject +# Uncomment the following to include local OPC UA SDK files, e.g. for debugging. +# You will also need to define the constant UseLocalOpcUaSdk in the file Directory.Build.targets. ++Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Opc.Ua.Configuration", "..\UA-.NETStandard\Libraries\Opc.Ua.Configuration\Opc.Ua.Configuration.csproj", "{19796333-27CA-461A-A3B3-96F7DB378F23}" ++EndProject ++Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Opc.Ua.Server", "..\UA-.NETStandard\Libraries\Opc.Ua.Server\Opc.Ua.Server.csproj", "{6D71B6B9-2A80-44A7-A5BE-E1012C2419E0}" ++EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/src/PlcServer.cs b/src/PlcServer.cs index 088cd7b..c985477 100644 --- a/src/PlcServer.cs +++ b/src/PlcServer.cs @@ -310,6 +310,17 @@ public override ResponseHeader Publish( return new ResponseHeader { ServiceResult = StatusCodes.BadSecureChannelIdInvalid }; } + catch (ServiceResultException ex) when (ex.StatusCode == StatusCodes.BadSessionClosed) + { + MetricsHelper.RecordTotalErrors(nameof(Publish)); + + LogErrorWithStatusCode( + nameof(Publish), + nameof(StatusCodes.BadSessionClosed), + ex); + + return new ResponseHeader { ServiceResult = StatusCodes.BadSessionClosed }; + } catch (Exception ex) { MetricsHelper.RecordTotalErrors(nameof(Publish)); diff --git a/src/opc-plc.csproj b/src/opc-plc.csproj index 77bd405..4a4c922 100644 --- a/src/opc-plc.csproj +++ b/src/opc-plc.csproj @@ -39,19 +39,28 @@ + + + + + + + + + + + - + - - - - - + + + - +