Skip to main content
 首页 » 编程设计

python之带有 python-firebase 的 Firebase 抛出 "Connection reset by peer"(Celery + gevent 参与)

2025年05月04日11rubylouvre

我正在使用 python-firebase在我的堆栈中记录点击次数和其他事件数据。它工作正常,但时不时地抛出这个堆栈跟踪:

'ConnectionError(MaxRetryError("HTTPSConnectionPool(host=\'somebase.firebaseio.com\', 
port=443): Max retries exceeded with url: /campaigns/79/clicked.json 
(Caused by <class \'socket.error\'>: [Errno 104] Connection reset by peer)",),)' 

这通常发生在高峰加载时间,但我知道我没有超过开发者计划中提供的 50 个最大连接数:

一些更多的数据:

点击计数更新发生在使用 Celery 和 gevent 的任务队列中。会不会是Gevent引起的?

更新:

另一个错误:

Task core.campaign.tasks.process_entry_click with id  
932df1ff-62a4-4d24-b491-b9b4921a2372 raised exception: 
"SSLError(SSLError(SSLError('The read operation timed out',),),)" 

请您参考如下方法:

这可能发生在服务器代码推送或停机期间(记录在 https://twitter.com/FirebaseStatus ) - 最好捕获此类异常并在服务器再次响应时重试。