Estoy tratando de configurar un silo Orleans dentro de un contenedor Docker . El cliente no estará en un contenedor al principio.
Estoy usando Docker en Windows en modo contenedor de Linux . Puedo tener tanto el cliente como el silo ejecutándose y conectándose cuando el cliente también está en un contenedor.
El silo se configura así:
var builder = new SiloHostBuilder() .Configure<ClusterOptions>(options => { options.ClusterId = "DOCKER-SILO"; options.ServiceId = "EZ-DOCKER"; }) .UseAdoNetClustering(options => { options.Invariant = "MySql.Data.MySqlClient"; options.ConnectionString = "server=XXX;user id=orleans;password='XXX';persistsecurityinfo=True;database=orleans;SslMode=None"; }) .Configure<EndpointOptions>(options => { var adressList = Dns.GetHostEntry(Dns.GetHostName()).AddressList; options.AdvertisedIPAddress = adressList.First(); options.GatewayPort = 30000); options.SiloPort = 11111); })El cliente está configurado así:
client = new ClientBuilder() .Configure<ClusterOptions>(options => { options.ClusterId = "DOCKER-SILO"; options.ServiceId = "EZ-DOCKER"; }) .UseStaticClustering(new IPEndPoint(IPAddress.Parse("192.168.0.13"), 30000))El silo se ejecuta así:
PS C:\XXX> docker run -p 30000:30000 --expose 11111 --add-host host.docker.internal:192.168.0.13 ezorleanssilolinuxDockerfile es bastante simple:
FROM mcr.microsoft.com/dotnet/core/runtime:2.1-stretch-slim AS base WORKDIR /app FROM base AS final WORKDIR /app #COPY --from=publish /app . COPY ["eZ.Orleans.Silo/publish", "."] ENTRYPOINT ["dotnet", "eZ.Orleans.Silo.dll"] Cuando uso 127.0.0.1 como IP de puerta de enlace estática en el cliente, funciona. Cuando uso cualquier otra IP que tenga el host docker, aparece el siguiente error en los registros del silo:
Gateway received unexpected non-proxied connection from *sgn/01111111-1111-1111-1111-111111111111/11111111 at source address 172.17.0.1:38428 ¿Por qué recibo este error cuando intento en cualquier otra dirección que no sea localhost? netstat -n -a me muestra que el silo está escuchando en 0.0.0.0 en el host.
después de unas horas logré que todo funcionara, mira mi Código de Silo:
return new HostBuilder() .UseOrleans(builder => { builder .UseDashboard() .UseAdoNetClustering(options => { options.Invariant = "System.Data.SqlClient"; options.ConnectionString = _connectionString; }) .Configure<EndpointOptions>(options => { // Port to use for Silo-to-Silo options.SiloPort = 11111; // Port to use for the gateway options.GatewayPort = 30000; // IP Address to advertise in the cluster options.AdvertisedIPAddress = IPAddress.Parse(GetExternalIpAddress()); // The socket used for silo-to-silo will bind to this endpoint options.GatewayListeningEndpoint = new IPEndPoint(IPAddress.Any, 40000); // The socket used by the gateway will bind to this endpoint options.SiloListeningEndpoint = new IPEndPoint(IPAddress.Any, 50000); }) .Configure<ClusterOptions>(options => { options.ClusterId = "ClusterId-ForSign"; options.ServiceId = "ServiceId-ForSign"; }) .ConfigureApplicationParts(parts => { parts.AddApplicationPart(typeof(UserService).Assembly).WithReferences(); parts.AddApplicationPart(typeof(CompanyService).Assembly).WithReferences(); }); }) .ConfigureServices(services => { services.AddTransient<ICompanyRepository, CompanyRepository>(); services.AddTransient<ICompanyService, CompanyService>(); services.Configure<ConsoleLifetimeOptions>(options => { options.SuppressStatusMessages = true; }); }) .ConfigureLogging(builder => { builder.AddConsole(); }) .RunConsoleAsync(); } private static string GetExternalIpAddress() => new WebClient().DownloadString("https://api.ipify.org");