I am using Python3.6 to get connection to RabbitMQ. This connection uses TLSv1.2 protocol. Setting the connection parameters for SSL:
cxt = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
ssl_options = pika.SSLOptions(context=cxt, server_hostname=rabbit_config['HOST'])
conn_params = pika.ConnectionParameters(port=rabbit_config['PORT'],
ssl_options=ssl_options,
credentials=creds,
virtual_host=rabbit_config['VIRTUAL_HOST'],
channel_max=channel_size,
heartbeat=heart_beat)
Getting following error when connecting to rabbitMq:
AMQPConnectionError: (AMQPConnectorSocketConnectError: ConnectionRefusedError(61, 'Connection refused'),)
I have referred pika docs for Connection Parameters, and TLS params example, but no success so far.
The similar code to connect to same Rabbit host is woriking in Java:
@Bean
CachingConnectionFactory connectionFactory(String host,
Integer port, String username,
String password, boolean ssl,
String sslAlgorithm) throws KeyManagementException, NoSuchAlgorithmException {
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setHost(host);
connectionFactory.setPort(port);
connectionFactory.setUsername(username);
connectionFactory.setPassword(password);
if (ssl) {
connectionFactory.useSslProtocol();
connectionFactory.useSslProtocol(sslAlgorithm);
}
CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory(connectionFactory);
cachingConnectionFactory.setRequestedHeartBeat(50);
cachingConnectionFactory.setChannelCacheSize(10);
return cachingConnectionFactory;
}