Handling Guidance on Handling SSLEOFError in Pika

11 views
Skip to first unread message

Ishika Kumari

unread,
Jan 28, 2025, 9:23:49 AMJan 28
to Pika

Dear Pika Team,

I hope this email finds you well. I am writing to seek your guidance regarding an issue I have been encountering while using the Pika library to consume messages from RabbitMQ over an SSL connection.

Issue Description

The application establishes a connection and consumes messages successfully for some time. However, after processing a few requests, it fails with the following error:

pika.exceptions.StreamLostError: Stream connection lost: SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:2548)’)

We also observed that error is only produced when the machine is close to 100% CPU usage.

Full Traceback

ERROR | 2025-01-25 07:23:49,053 | Error in RabbitMQ consumption
Traceback (most recent call last):
File "/data/./cashapps/lockbox/main.py", line 93, in start_consumption
input_rmq_channel.start_consuming()
File "/usr/local/lib/python3.10/site-packages/pika/adapters/blocking_connection.py", line 1880, in start_consuming
self._process_data_events(time_limit=None)
File "/usr/local/lib/python3.10/site-packages/pika/adapters/blocking_connection.py", line 2041, in _process_data_events
self.connection.process_data_events(time_limit=time_limit)
File "/usr/local/lib/python3.10/site-packages/pika/adapters/blocking_connection.py", line 848, in process_data_events
self._dispatch_channel_events()
File "/usr/local/lib/python3.10/site-packages/pika/adapters/blocking_connection.py", line 567, in _dispatch_channel_events
impl_channel._get_cookie()._dispatch_events()
File "/usr/local/lib/python3.10/site-packages/pika/adapters/blocking_connection.py", line 1507, in _dispatch_events
consumer_info.on_message_callback(self, evt.method,
File "/data/./cashapps/lockbox/main.py", line 66, in run_remittance_ml_application
self.output_rmq_channel.basic_publish(
File "/usr/local/lib/python3.10/site-packages/pika/adapters/blocking_connection.py", line 2262, in basic_publish
self._flush_output()
File "/usr/local/lib/python3.10/site-packages/pika/adapters/blocking_connection.py", line 1350, in _flush_output
self._connection._flush_output(lambda: self.is_closed, *waiters)
File "/usr/local/lib/python3.10/site-packages/pika/adapters/blocking_connection.py", line 523, in _flush_output
raise self._closed_result.value.error
pika.exceptions.StreamLostError: Stream connection lost: SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:2548)')

Environment Details
  • Pika Version: 1.3.0
  • Python Version: 3.10
  • RabbitMQ Version: 3.11.28
  • Connection: SSL/TLS with pika.BlockingConnection
  • Heartbeat Timeout: 600 seconds
Python Code
def start_consumption(self):
"""Start the RabbitMQ consumption"""
try:
# Define consumer queues
input_rmq_channel = self.rmq_connection.channel()
input_rmq_channel.queue_declare(
queue=self.input_queue, durable=True
)
input_rmq_channel.basic_qos(prefetch_count=1)

# Define publisher queues
self.output_rmq_channel = self.rmq_connection.channel()
self.output_rmq_channel.queue_declare(
queue=self.output_queue, durable=True
)

input_rmq_channel.basic_consume(
queue=self.input_queue,
on_message_callback=self.run_remittance_ml_application,
)
input_rmq_channel.start_consuming()
except Exception as exec:
logger.error("Error in RabbitMQ consumption", exc_info=exec.__traceback__)
raise RuntimeError(f"Error in RabbitMQ consumption: {str(exec)}") from exec

Troubleshooting Steps Taken
  1. Verified that SSL/TLS setup (certificates, RabbitMQ server config) is correct.
  2. Ensured durable queues and proper message acknowledgment (basic_ack).
  3. Tested with varying heartbeat timeout values to rule out timeout-related issues.

Despite these efforts, the issue persists intermittently, which makes it challenging to identify a root cause.

Request for Guidance

I would greatly appreciate your assistance on the following:

  1. Could this error indicate an issue with the way Pika handles SSL/TLS connections, or is it likely related to server-side or network-level interruptions?
  2. Are there best practices for handling such intermittent SSL errors in Pika?
  3. Would switching to asynchronous connections (e.g., SelectConnection) or any other specific configuration in Pika help address this issue?

If there are additional debugging steps or configurations you recommend, please let me know.

Thank you for your time and support. I look forward to hearing from you.

Best regards,
Ishika Kumari

ML Engineer

Growfin.ai

Reply all
Reply to author
Forward
0 new messages