Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overriding the host name does not work consistently #7026

Closed
SzymonPobiega opened this issue May 14, 2024 · 1 comment · Fixed by #7282
Closed

Overriding the host name does not work consistently #7026

SzymonPobiega opened this issue May 14, 2024 · 1 comment · Fixed by #7282
Milestone

Comments

@SzymonPobiega
Copy link
Member

SzymonPobiega commented May 14, 2024

Symptoms

When using config.UniquelyIdentifyRunningInstance().UsingHostName("MyHost") to override the host name, the ServicePulse Endpoint Heartbeats feature fails to display the overridden host name.

Who's affected

You are affected if your endpoints are set to override the default hostname using UsingHostName.

Root cause

The current implementation overrides the host name but does not override the host display name used by ServiceControl and ServicePulse.

Backported to

Description

Overriding the hostname using the API introduced in NServiceBus 8

config.UniquelyIdentifyRunningInstance().UsingHostName("MyHost")

does not change the host name.

Expected behavior

Host name is set to the desired value.

Actual behavior

Host name (as obtained from the HostInformation public API) is not changed and always defaults to Environment.MachineName.

One of the places where this is clearly visible is the heartbeats feature. The heartbeat messages carry the wrong value.

Versions

The problem has been discovered in NServiceBus 8.2 but likely exists in all V8 and V9 versions

Steps to reproduce

  1. Override the host name using config.UniquelyIdentifyRunningInstance().UsingHostName("MyHost")
  2. Add the heartbeat plugin
  3. Run the endpoint using the Learning Transport
  4. Observe the Host filed in the heartbeat messages being set to the default value -- Environment.MachineName

Relevant log output

No response

Additional Information

Workarounds

The workaround in V8 is to use the legacy deprecated API:

#pragma warning disable CS0618 // Type or member is obsolete
RuntimeEnvironment.MachineNameAction = () => "MyMachine";
#pragma warning restore CS0618 // Type or member is obsolete

Possible solutions

Additional information

Combined with a bug in the heartbeat state machine handling in ServiceControl this issue leads to an endless loop of heartbeat stopped-heartbeat restored events generated by ServiceControl after one of the monitored endpoints is upgraded from NServiceBus 7 to NServiceBus 8 and re-deployed.

@jasontaylordev
Copy link
Contributor

Will be shipped with NServiceBus releases 9.2.6, 9.1.4, and 8.2.5.

@jasontaylordev jasontaylordev modified the milestones: 9.2.6, 9.1.4 Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants