Is there a connection retry for the transport?

If you want to use Endpoint.Start(configuration) then you must add the endpoint configuration creation in it too.

I purposefully used the Create and Start API’s as I assume the queues and database schemas would already be created and then .EnableInstallers() does not need to be called which is probably the reason you currently are getting exceptions.

Either:

  • Remove .EnableInstallers() when you initialize the EndpointConfiguration
  • Add the creation of EndpointConfiguration to this method
  • Pass a func to this method to split the endpoint configuration

Implementation that uses a func:

static class EndpointHelper
{
    public static async Task<IEndpointInstance> CreateWithRetry(
        Func<EndpointConfiguration> createEndpointConfiguration,
        int maxAttempts = 10
        )
    {
        var attempts = 0;
        while (true)
        {
            try
            {
                var endpointConfiguration = createEndpointConfiguration();
                return await Endpoint.Start(endpointConfiguration)
                    .ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                if (attempts > maxAttempts) throw;
                var delay = 100 * (int)Math.Pow(2, attempts++);
                await Console.Out.WriteLineAsync($"Startup failed, retry attempt {attempts} reason: {ex.Message}")
                    .ConfigureAwait(false);

                await Task.Delay(delay).ConfigureAwait(false);
            }
        }
    }
}

and you could use it like:

var endpointInstance = await EndpointHelper.CreateWithRetry(() => CreateEndpointConfiguration())
    .ConfigureAwait(false);

static EndpointConfiguration CreateEndpointConfiguration()
{
    var cfg = new EndpointConfiguration("MyEndpoint");
    cfg.EnableInstallers();
    cfg.UseTransport<LearningTransport>();
    cfg.UsePersistence<LearningPersistence>();
    //etc...
    return cfg;
}