Skip to content

Commit

Permalink
fix(process-chunks): fix connection to aws mq
Browse files Browse the repository at this point in the history
  • Loading branch information
EchoSkorJjj committed Apr 22, 2024
1 parent 3961ac5 commit 0ab081b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion backend/complex/process-chunks/src/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import grpc
import pika
import ssl
import os
import re
import json
Expand Down Expand Up @@ -42,8 +43,19 @@ def initialize_api_key_cycle(self):

def initialize_rabbitmq(self):
"""Initializes the RabbitMQ connection and channels."""

ssl_context = None
if os.getenv("ENVIRONMENT") == "production":
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
ssl_context.set_ciphers('ECDHE+AESGCM:!ECDSA')

credentials = pika.PlainCredentials(self.RABBITMQ_USERNAME, self.RABBITMQ_PASSWORD)
connection_parameters = pika.ConnectionParameters(host=self.RABBITMQ_SERVER, credentials=credentials)
connection_parameters = pika.ConnectionParameters(
host=self.RABBITMQ_SERVER,
credentials=credentials,
ssl_options=pika.SSLOptions(context=ssl_context) if ssl_context else None
)

self.connection = pika.BlockingConnection(connection_parameters)
self.channel = self.connection.channel()
self.channel.queue_declare(queue=self.QUEUE_NAME_1, durable=True)
Expand Down

0 comments on commit 0ab081b

Please sign in to comment.