How to change ServerName

Tags: #<Tag:0x00007f1862ed1af8>

Hi, I see in the sourcecode of BackgroundJobServerOptions:

[Obsolete(“Server Id is auto-generated now, and this option does not make sense anymore. Will be removed in 2.0.0.”)]
public string ServerName { get; set; }

I’m using an Azure WebApp for processing but this generates server names like:
RD000D3A213ADE:7356:83D05306-711D-4617-9F1B-A41B79AC94B2

How can I change this to a more readable format?

Thanks,
Marc

The name is made up of three parts

  1. RD000D3A213ADE. This is the actual name of the physical server your code is running on. Since you mention you’re on Azure the changes being able to change this are low.
  2. 7356 This is the port that your webapp is listening on.
  3. 83D05306-711D-4617-9F1B-A41B79AC94B2 This is a generated GUID for your instance to make sure you don’t have a naming-conflict in the case you run multiple Hangfire’s in the same process.

You can theoretically change the first two parts by renaming the server you’re running and using a different port, by in practice the ServerName is assigned by Hangfire and not something you should change.

What about if I’m running two clients on one machine? In my (test) setup, I’ve got a console application and a windows service running on the same machine, how am I to distinguish between them meanfully?

Wouldn’t it be nice if we could assign a human-friendly name, and have the application assign an Id.

On my production machine this results in:

(so no duplicate machines here))

Having the same issue. Did you find any solution to this? (How to distinguish between multiple instances on the same machine)

This has been fixed in https://github.com/HangfireIO/Hangfire/releases/tag/v1.6.0, see: BackgroundJobServerOptions.ServerName option is back., so you can set the server name yourself.

1 Like