[Server Bootstrapper] ERROR Hangfire.Server.ServerBootstrapper

I’m seeing this error in the logs repeatedly. What is cause? Looks like a column length in one of the tables created in hangfire scheme is not long enough.

Error occurred during execution of ‘Server Bootstrapper’ component. Execution will be retried (attempt 20 of 2147483647) in 00:05:00 seconds.
Npgsql.NpgsqlException:
value too long for type character varying(50)
Severity: ERROR
Code: 22001
at Npgsql.NpgsqlState.d__0.MoveNext()
at Npgsql.ForwardsOnlyDataReader.GetNextResponseObject(Boolean cleanup)
at Npgsql.ForwardsOnlyDataReader.GetNextRowDescription()
at Npgsql.ForwardsOnlyDataReader.NextResultInternal()
at Npgsql.ForwardsOnlyDataReader…ctor(IEnumerable1 dataEnumeration, CommandBehavior behavior, NpgsqlCommand command, NotificationThreadBlock threadBlock, Boolean preparedStatement, NpgsqlRowDescription rowDescription) at Npgsql.NpgsqlCommand.GetReader(CommandBehavior cb) at Npgsql.NpgsqlCommand.ExecuteNonQuery() at Dapper.SqlMapper.ExecuteCommand(IDbConnection cnn, CommandDefinition& command, Action2 paramReader)
at Dapper.SqlMapper.ExecuteImpl(IDbConnection cnn, CommandDefinition& command)
at Dapper.SqlMapper.Execute(IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Nullable1 commandTimeout, Nullable1 commandType)
at Hangfire.PostgreSql.PostgreSqlConnection.AnnounceServer(String serverId, ServerContext context)
at Hangfire.Server.ServerBootstrapper.Execute(CancellationToken cancellationToken)
at Hangfire.Server.AutomaticRetryServerComponentWrapper.ExecuteWithAutomaticRetry(CancellationToken cancellationToken)

I only see one column setup as character varying (50) and that is id column in the server table.
and my server name is much smaller than 50 chars so not sure why i’m seeing this error message in my logs.

Hi @topish, what exactly is your server name? Please post here the code that contains assignment to ServerName property. Please note that Hangfire appends a given server name with the process identifier, but it is usually 4-6 characters.

So the server name is being saved as ztrldnb118:5372, machine name: some hangfire generated integer.
This is just using the defaults,
I’m not sure why I see the string truncation issue. Clearly under 50 chars right there.

               var sb =
                new NpgsqlConnectionStringBuilder(
                    ConfigurationManager.ConnectionStrings["connection_config"].ConnectionString)
                {
                    Pooling = false
                };

            var storage = new PostgreSqlStorage(sb.ConnectionString);
            Hangfire.GlobalConfiguration.Configuration.UseStorage(storage);
            JobStorage.Current = storage;
            Hangfire.GlobalConfiguration.Configuration.UseLog4NetLogProvider();

            hf.UseHangfireServer();

            var svc = SomeUrl.AbsolutePath;
            hf.UseHangfireDashboard("/dashboard",
                new DashboardOptions
                {
                    AppPath = VirtualPathUtility.ToAbsolute(svc),
                    AuthorizationFilters = Enumerable.Empty<Hangfire.Dashboard.IAuthorizationFilter>()
                }, storage);

When I try modifying the server name or the worker count as illustrated in the docs, I am unable to have any available servers.
The following doesn’t work when inserting this code before the call to UseHangfireServer in the above example.

           var options = new BackgroundJobServerOptions
            {
                WorkerCount = 25,
                ServerName = string.Format("{0}.{1}".FormatWith(Environment.MachineName, Guid.NewGuid()))
            };

            var server = new BackgroundJobServer(options, storage);
            hf.UseHangfireServer(options, storage);

Are you using the dev branch ? It looks like the generated server name now includes a GUID which is appended to the end:
https://github.com/HangfireIO/Hangfire/blob/dev/src/Hangfire.Core/Server/BackgroundServer.cs#L111

nope, not dev branch. would be latest nuget version.