-
Notifications
You must be signed in to change notification settings - Fork 620
Description
The exception as below:
RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the specified endpoints were reachable ---> System.AggregateException: One or more errors occurred. (Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.) ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
--- End of inner exception stack trace ---
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.Security.SslStream.BeginAuthenticateAsClient(SslClientAuthenticationOptions sslClientAuthenticationOptions, CancellationToken cancellationToken, AsyncCallback asyncCallback, Object asyncState)
at System.Net.Security.SslStream.BeginAuthenticateAsClient(String targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation, AsyncCallback asyncCallback, Object asyncState)
at System.Net.Security.SslStream.<>c.b__46_1(String arg1, X509CertificateCollection arg2, SslProtocols arg3, AsyncCallback callback, Object state)
at System.Threading.Tasks.TaskFactory1.FromAsyncImpl[TArg1,TArg2,TArg3](Func6 beginMethod, Func2 endFunction, Action1 endAction, TArg1 arg1, TArg2 arg2, TArg3 arg3, Object state, TaskCreationOptions creationOptions)
at System.Threading.Tasks.TaskFactory.FromAsync[TArg1,TArg2,TArg3](Func6 beginMethod, Action1 endMethod, TArg1 arg1, TArg2 arg2, TArg3 arg3, Object state)
at System.Net.Security.SslStream.AuthenticateAsClientAsync(String targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation)
at RabbitMQ.Client.Impl.SslHelper.<>c__DisplayClass2_0.b__0(SslOption opts) in //projects/RabbitMQ.Client/client/impl/SslHelper.cs:line 77
at RabbitMQ.Client.Impl.SslHelper.TcpUpgrade(Stream tcpStream, SslOption options) in //projects/RabbitMQ.Client/client/impl/SslHelper.cs:line 81
at RabbitMQ.Client.Impl.SocketFrameHandler..ctor(AmqpTcpEndpoint endpoint, Func2 socketFactory, TimeSpan connectionTimeout, TimeSpan readTimeout, TimeSpan writeTimeout) in /_/projects/RabbitMQ.Client/client/impl/SocketFrameHandler.cs:line 109 at RabbitMQ.Client.ConnectionFactory.CreateFrameHandler(AmqpTcpEndpoint endpoint) in /_/projects/RabbitMQ.Client/client/api/ConnectionFactory.cs:line 510 at RabbitMQ.Client.EndpointResolverExtensions.SelectOne[T](IEndpointResolver resolver, Func2 selector) in //projects/RabbitMQ.Client/client/api/IEndpointResolverExtensions.cs:line 56
--- End of inner exception stack trace ---
at RabbitMQ.Client.EndpointResolverExtensions.SelectOne[T](IEndpointResolver resolver, Func`2 selector) in //projects/RabbitMQ.Client/client/api/IEndpointResolverExtensions.cs:line 70
at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection.Init(IEndpointResolver endpoints) in //projects/RabbitMQ.Client/client/impl/AutorecoveringConnection.cs:line 468
at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName) in //projects/RabbitMQ.Client/client/api/ConnectionFactory.cs:line 492
--- End of inner exception stack trace ---
at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName) in /_/projects/RabbitMQ.Client/client/api/ConnectionFactory.cs:line 502
at tap.infras.mq.Provider.RabbitMq.RabbitMqConnectionFactory.CreateIConnection(String userName, String password, String hostName) in D:\WorkSpace\common\tap.common\tap.infras\mq\Provider\RabbitMq\RabbitMqConnectionFactory.cs:line 23
System.MissingMethodException: No parameterless constructor defined for this object.
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean skipCheckThis, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
at tap.infras.mq.Switch.MessageHandleManager.Init() in D:\WorkSpace\common\tap.common\tap.infras\mq\Switch\MessageHandleManager.cs:line 91
My code as below:
ConnectionFactory factory = new ConnectionFactory();
factory.Ssl = new SslOption();
factory.Ssl.Enabled = true;
factory.Ssl.ServerName = "111111111";
factory.Ssl.CertPath = "22222222.p12";
factory.Ssl.CertPassphrase = "3333333";
factory.Ssl.Version = System.Security.Authentication.SslProtocols.Tls12;
factory.UserName = userName;
factory.Password = password;
factory.HostName = hostName;
factory.Port = 5671;
var connection = factory.CreateConnection();
My rabbitmq.config as below:
[
{rabbit, [{log, [
{file, [{level, debug}]},
{categories, [
{connection, [{level, info}]},
{channel, [{level, info}]}
]}
]},
{ssl_listeners, [5671]},
{ssl_options, [{cacertfile,"C:/Program Files/RabbitMQ Server/abbitmq_server-3.8.3/etc/Cert/root-cert.cer"},
{certfile,"C:/Program Files/RabbitMQ Server/abbitmq_server-3.8.3/etc/Cert/root-cert.cer"},
{keyfile,"C:/Program Files/RabbitMQ Server/abbitmq_server-3.8.3/etc/Cert/root-key.key"},
{depth, 2},
{verify,verify_peer},
{fail_if_no_peer_cert,false},
{versions, ['tlsv1.2']},
{ciphers, [
"ECDHE-ECDSA-AES256-GCM-SHA384",
"ECDHE-RSA-AES256-GCM-SHA384",
"ECDH-ECDSA-AES256-GCM-SHA384",
"ECDH-RSA-AES256-GCM-SHA384",
"DHE-RSA-AES256-GCM-SHA384",
"DHE-DSS-AES256-GCM-SHA384",
"ECDHE-ECDSA-AES128-GCM-SHA256",
"ECDHE-RSA-AES128-GCM-SHA256",
"ECDH-ECDSA-AES128-GCM-SHA256",
"ECDH-RSA-AES128-GCM-SHA256",
"DHE-RSA-AES128-GCM-SHA256",
"DHE-DSS-AES128-GCM-SHA256"
]}
]}
]}
].