Skip to content

Commit

Permalink
Improve publish BadSessionIdInvalid and BadSecureChannelIdInvalid (#378)
Browse files Browse the repository at this point in the history
* Handle more errors during publish

* Update version
  • Loading branch information
luiscantero authored Jul 25, 2024
1 parent a4dfb11 commit 3328ca9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
36 changes: 28 additions & 8 deletions src/PlcServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,20 +220,40 @@ public override ResponseHeader Publish(
{
MetricsHelper.RecordTotalErrors(nameof(Publish));

subscriptionId = default;
availableSequenceNumbers = default;
moreNotifications = default;
notificationMessage = default;
results = default;
diagnosticInfos = default;

if (ex.Message == StatusCodes.BadNoSubscription.ToString())
{
_logger.LogDebug("Failed to publish: BadNoSubscription");

subscriptionId = default;
availableSequenceNumbers = default;
moreNotifications = default;
notificationMessage = default;
results = default;
diagnosticInfos = default;
_logger.LogDebug(
"Failed to publish: {StatusCode}",
StatusCodes.BadNoSubscription.ToString());

return new ResponseHeader { ServiceResult = StatusCodes.BadNoSubscription };
}

if (ex.Message == StatusCodes.BadSessionIdInvalid.ToString())
{
_logger.LogDebug(
"Failed to publish: {StatusCode}",
StatusCodes.BadSessionIdInvalid.ToString());

return new ResponseHeader { ServiceResult = StatusCodes.BadSessionIdInvalid };
}

if (ex.Message == StatusCodes.BadSecureChannelIdInvalid.ToString())
{
_logger.LogDebug(
"Failed to publish: {StatusCode}",
StatusCodes.BadSecureChannelIdInvalid.ToString());

return new ResponseHeader { ServiceResult = StatusCodes.BadSecureChannelIdInvalid };
}

_logger.LogError(ex, "Error publishing");
throw;
}
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "2.12.18",
"version": "2.12.19",
"versionHeightOffset": -1,
"publicReleaseRefSpec": [
"^refs/heads/main$",
Expand Down

0 comments on commit 3328ca9

Please sign in to comment.