1

私は Python3.6 を使用して RabbitMQ に接続しています。この接続は TLSv1.2 プロトコルを使用します。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)

rabbitMq への接続時に次のエラーが発生します。

AMQPConnectionError: (AMQPConnectorSocketConnectError: ConnectionRefusedError(61, 'Connection refused'),)

Connection ParametersTLS params exampleについて pika docs を参照しましたが、これまでのところ成功していません。

Java では、同じ Rabbit ホストに接続するための同様のコードが機能しています。

    @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;
    }
4

1 に答える 1