I am connecting to a PostgreSQL server using EF Core and Npgsql.
Sometimes I get a System.Net.Socket.SocketException 11001 “No such host is known”, and we want to treat this exception as transient and let the build in retry mechanism try again.
The NpgsqlDbContextOptionsBuilder
has an EnableRetryOnFailure(...)
that takes an optional collection of strings of error codes.
optionsBuilder.UseNpgsql(connectionString, providerOptions =>
{
providerOptions.EnableRetryOnFailure(errorCodesToAdd: ????);
});
Does anyone know what error code I should add here to enable retry when I get the socket exception. The exception is not considered transient by default. I’ve tried to look in the documentation for an answer but have not found any.