Reputation: 21
I’m new to rabbitmq but I have to connect to remote broker to send and receive messages. Remote server is out of my control and it’s almost impossible to get answers from its team. Nevertheless, I have address, port, virtual host and user credentials at my disposal. Server uses TLS v1.2. The problem is I cannot establish connection to the server with .NET client. Client is “rabbitmq.client.5.1.0”, .NET Framework 4.5.1 and VS 2017. My code is:
public bool Start() {
try {
var f = new ConnectionFactory();
f.UserName = "TestUser";
f.Password = "TestPwd";
f.HostName = "x.x.x.x";
f.Port = 5673;
f.VirtualHost = "TestVH";
f.Ssl.Version = SslProtocols.Tls12;
f.Ssl.Enabled = true;
f.Ssl.AcceptablePolicyErrors = SslPolicyErrors.RemoteCertificateChainErrors
| SslPolicyErrors.RemoteCertificateNameMismatch
| SslPolicyErrors.RemoteCertificateNotAvailable;
var c = f.CreateConnection();
} catch( Exception e ) {
throw e;
}
}
It throws an exception which innermost is:
Authentication failed because the remote party has closed the transport stream.
If I do it with Java (1.8, amqp-client-4.0.2
), I can successfully connect to the server.
public static void main( String[] args ) throws Exception{
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("x.x.x.x");
factory.setPort(5673);
factory.setUsername( "TestUser" );
factory.setPassword( "TestPwd" );
factory.setVirtualHost( "TestVH" );
factory.useSslProtocol("TLSv1.2");
Connection conn = factory.newConnection();
}
I would like to use C# to get the job done but I can not sort this thing out. Any help would be greatly appreciated!
Upvotes: 2
Views: 989
Reputation: 5801
try changing this line:
f.Ssl.Version = SslProtocols.Tls12;
to this:
f.Ssl.Version = SslProtocols.Tls12 | SslProtocols.Ssl3 | SslProtocols.Tls11 | SslProtocols.Ssl2;
If that works then you narrow them down
Upvotes: 2