antonyvorontsov / RabbitMQ.Client.Core.DependencyInjection

.Net Core library-wrapper of RabbitMQ.Client for Dependency Injection.
MIT License
111 stars 36 forks source link

Unable to create rabbitmq connection with SSLProducer example #68

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hello, I'm receiving errors when replicating sslProducer example - https://github.com/AntonyVorontsov/RabbitMQ.Client.Core.DependencyInjection/blob/master/examples/Examples.SslProducer/appsettings.json on my end.

errors are occurred at this line - `IConfigurationSection rabbitMqSection = _configuration.GetSection("RabbitMq"); IConfigurationSection exchangeSection = _configuration.GetSection("RabbitMqExchange"); string exchangeName = exchangeSection.GetSection("Name").Value; string routingKey = exchangeSection.GetSection("Queues:0:RoutingKeys:0").Value;

        IServiceCollection services = new ServiceCollection();
        services.AddLogging(builder => builder.AddConsole());
        services.AddRabbitMqClient(rabbitMqSection)
            .AddProductionExchange(exchangeName, exchangeSection);

        IServiceProvider sp = services.BuildServiceProvider();
        IQueueService queueService = sp.GetRequiredService<IQueueService>(); ///// errors were thrown here

        await PublishMessagesAsync(queueService, exchangeName, routingKey);
        Console.ReadLine();`

errors are following

here is my appsettings - "RabbitMq": { "TcpEndpoints": [ { "HostName": "xxx.xx.xxx.152", "Port": 5671, "SslOption": { "Enabled": true, "ServerName": "server-name", "CertificatePath": "C:/Users/username/client/client_certificate.p12", "CertificatePassphrase": "MySecretPassword", "AcceptablePolicyErrors": "RemoteCertificateChainErrors, RemoteCertificateNameMismatch" } } ], "UserName": "guest", "Password": "guest" }, "RabbitMqExchange": { "Name": "Test2.Exchange", "Type": "fanout", "Durable": true, "Queues": [ { "Name": "test-queue", "Durable": true, "RoutingKeys": [ "test-queue_key" ] }, { "Name": "test2-queue", "Durable": true, "RoutingKeys": [ "test-queue_key" ] } ] }

please advice what to do.

ghost commented 3 years ago

@AntonyVorontsov please advise on this issue.