dotnet / orleans

Cloud Native application framework for .NET
https://docs.microsoft.com/dotnet/orleans
MIT License
10.04k stars 2.02k forks source link

Unintuitive error when client setup to use TLS and Silo is Not. #7515

Open ElanHasson opened 2 years ago

ElanHasson commented 2 years ago

Error from Silo:

[07:54:57 DBG] Connection id "0HMF0P8SN4092" received FIN.
[07:54:57 WRN] Error processing connection [Local: 172.16.1.20:30000, Remote: 172.16.1.20:52169, ConnectionId: 0HMF0P8SN4092]
System.InvalidOperationException: Connection terminated prematurely
   at Orleans.Runtime.Messaging.ConnectionPreamble.<Read>g__CheckForCompletion|3_1(ReadResult& r) in /_/src/Orleans.Core/Networking/ConnectionPreamble.cs:line 136
   at Orleans.Runtime.Messaging.ConnectionPreamble.Read(ConnectionContext connection) in /_/src/Orleans.Core/Networking/ConnectionPreamble.cs:line 68
   at Orleans.Runtime.Messaging.GatewayInboundConnection.ProcessConnection() in /_/src/Orleans.Runtime/Networking/GatewayInboundConnection.cs:line 121
   at Orleans.Runtime.Messaging.Connection.Run() in /_/src/Orleans.Core/Networking/Connection.cs:line 185
[07:54:57 DBG] Connection id "0HMF0P8SN4092" sending FIN because: "The Socket transport's send loop completed gracefully."
[07:54:57 INF] Connection [Local: 172.16.1.20:30000, Remote: 172.16.1.20:52169, ConnectionId: 0HMF0P8SN4092] terminated
[07:54:57 DBG] Connection id "0HMF0P8SN4093" received FIN.

Config:

  siloBuilder
            .ConfigureServices(
                (context, services) =>
                {
                    services.Configure<ApplicationOptions>(context.Configuration);
                    services.Configure<ClusterMembershipOptions>(context.Configuration.GetSection(nameof(ApplicationOptions.ClusterMembership)));
                    services.Configure<ClusterOptions>(context.Configuration.GetSection(nameof(ApplicationOptions.Cluster)));
                    services.Configure<StorageOptions>(context.Configuration.GetSection(nameof(ApplicationOptions.Storage)));
                })
            .UseSiloUnobservedExceptionsHandler()
            .UseAdoNetClustering(options =>
            {
                options.Invariant = GetStorageOptions(context.Configuration).Invariant;
                options.ConnectionString = GetStorageOptions(context.Configuration).ConnectionString;
            })
            .ConfigureEndpoints(
                EndpointOptions.DEFAULT_SILO_PORT,
                EndpointOptions.DEFAULT_GATEWAY_PORT,
                listenOnAnyHostAddress: !context.HostingEnvironment.IsDevelopment())
            .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(StorageHealthCheckGrain).Assembly).WithReferences())
            .AddAdoNetGrainStorageAsDefault(options =>
                {
                    options.Invariant = GetStorageOptions(context.Configuration).Invariant;
                    options.ConnectionString = GetStorageOptions(context.Configuration).ConnectionString;
                    options.ConfigureJsonSerializerSettings = ConfigureJsonSerializerSettings;
                    options.UseJsonFormat = true;
                })
              .AddAdoNetGrainStorage(GrainStorageProviderName.ScheduledTaskMetadata, options =>
              {
                  options.Invariant = GetStorageOptions(context.Configuration).Invariant;
                  options.ConnectionString = GetStorageOptions(context.Configuration).ConnectionString;
                  options.ConfigureJsonSerializerSettings = ConfigureJsonSerializerSettings;
                  options.UseJsonFormat = true;
              })
            .UseAdoNetReminderService(options =>
                {
                    options.Invariant = GetStorageOptions(context.Configuration).Invariant;
                    options.ConnectionString = GetStorageOptions(context.Configuration).ConnectionString;
                })
            //.UseTransactions(withStatisticsReporter: true)
            //.AddAzureTableTransactionalStateStorageAsDefault(
            //    options => options.ConnectionString = GetStorageOptions(context.Configuration).ConnectionString)
            .AddSimpleMessageStreamProvider(StreamProviderName.Default)
            .AddAdoNetGrainStorage(
                "PubSubStore",
                options =>
                {
                    options.Invariant = GetStorageOptions(context.Configuration).Invariant;
                    options.ConnectionString = GetStorageOptions(context.Configuration).ConnectionString;
                    options.ConfigureJsonSerializerSettings = ConfigureJsonSerializerSettings;
                    options.UseJsonFormat = true;
                })
            .UseIf(
                RuntimeInformation.IsOSPlatform(OSPlatform.Linux),
                x => x.UseLinuxEnvironmentStatistics())
            .UseIf(
                RuntimeInformation.IsOSPlatform(OSPlatform.Windows),
                x => x.UsePerfCounterEnvironmentStatistics())
            .UseDashboard();

Client:

Orleans.Networking.Shared.SocketConnectionException: Unable to connect to 172.16.1.20:30000. Error: ConnectionRefused
   at Orleans.Networking.Shared.SocketConnectionFactory.ConnectAsync(EndPoint endpoint, CancellationToken cancellationToken) in /_/src/Orleans.Core/Networking/Shared/SocketConnectionFactory.cs:line 52
   at Orleans.Runtime.Messaging.ConnectionFactory.ConnectAsync(SiloAddress address, CancellationToken cancellationToken) in /_/src/Orleans.Core/Networking/ConnectionFactory.cs:line 53
   at Orleans.Internal.OrleansTaskExtentions.MakeCancellable[T](Task`1 task, CancellationToken cancellationToken)
   at Orleans.Runtime.Messaging.ConnectionManager.ConnectAsync(SiloAddress address) in /_/src/Orleans.Core/Networking/ConnectionManager.cs:line 262

Setup:


        this.Client = new ClientBuilder()
            .UseAdoNetClustering(options =>
            {
                options.Invariant = this.options.Storage.Invariant;
                options.ConnectionString = this.options.Storage.ConnectionString;
            })
           .Configure<ClusterOptions>(options =>
           {
               options.ClusterId = this.options.Cluster.ClusterId;
               options.ServiceId = this.options.Cluster.ServiceId;
           })
           .ConfigureApplicationParts(
               parts => parts
                   .AddApplicationPart(typeof(Abstractions.Grains.HealthChecks.ILocalHealthCheckGrain).Assembly)
                   .WithReferences())
           .UseTls(
               options =>
               {
                   // TODO: Configure a certificate.
                   options.LocalCertificate = null;

                   // TODO: Do not allow any remote certificates in production.
                   options.AllowAnyRemoteCertificate();
              })
            .Build();
ghost commented 2 years ago

We've moved this issue to the Backlog. This means that it is not going to be worked on for the coming release. We review items in the backlog at the end of each milestone/release and depending on the team's priority we may reconsider this issue for the following milestone.