I’m encountering an SSL error while pushing data to Supabase using the httpx library in Python. The error message is [SSL: SSLV3_ALERT_BAD_RECORD_MAC] ssl/tls alert bad record mac (_ssl.c:2580). This issue occurs intermittently, usually after successfully pushing several batches of data.
Here is the relevant part of my code:
import time
import pandas as pd
import numpy as np
import supabase
class DataProcessor:
def __init__(self, push_url, push_key, df):
self.push_url = push_url
self.push_key = push_key
self.df = df
def process_data(self):
supabase_push = supabase.create_client(self.push_url, self.push_key)
df = self.df.replace({pd.NA: None, np.nan: None})
for i in range(0, len(df), 25000):
try:
data = df[i:i + 25000].to_dict(orient='records')
# Check for duplicate IDs and index
if len(df[i:i + 25000]['id'].unique()) != len(df[i:i + 25000]):
print('Duplicate IDs at index:', i)
break
if len(df[i:i + 25000].index.unique()) != len(df[i:i + 25000]):
print('Duplicate Index at index:', i)
break
data = supabase_push.table('budget_table').upsert(data).execute()
print('Pushed', i + 25000, 'rows')
except:
print('Retrying')
time.sleep(20)
supabase_push = supabase.create_client(self.push_url, self.push_key)
data = df[i:i + 25000].to_dict(orient='records')
data = supabase_push.table('budget_table').upsert(data).execute()
print('Pushed', i + 25000, 'rows')
df = pd.read_csv('feb_24.csv')
processor = DataProcessor('dev_url', 'dev_key', df, 0)
processor.process_data()
The error trace is as follows:
Retrying
Traceback (most recent call last):
File "/path/to/httpcore/_sync/http11.py", line 224, in _receive_event
data = self._network_stream.read()
File "/path/to/httpcore/_backends/sync.py", line 124, in read
with map_exceptions(exc_map):
File "/path/to/contextlib.py", line 158, in __exit__
self.gen.throw(typ, value, traceback)
File "/path/to/httpcore/_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.ReadError: [SSL: SSLV3_ALERT_BAD_RECORD_MAC] ssl/tls alert bad record mac (_ssl.c:2580)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/path/to/supabase/main.py", line 203, in process_data
data = supabase_push.table('event_pitching_v2').upsert(data).execute()
File "/path/to/httpx/_client.py", line 1015, in _send_single_request
response = transport.handle_request(request)
File "/path/to/httpx/_transports/default.py", line 86, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ReadError: [SSL: SSLV3_ALERT_BAD_RECORD_MAC] ssl/tls alert bad record mac (_ssl.c:2580)
Steps I’ve already tried:
• Updated all related libraries (httpx, httpcore, etc.) to the latest versions.
• Made sure the ID and Index were both unique.
It will sometimes upload batches of rows but is getting stuck on something. I apologize for my ignorance of working with cloud databases.