gpt4 book ai didi

python "[WARNING] Retrying after connection broken by SSLError"

转载 作者:行者123 更新时间:2023-12-04 22:41:37 31 4
gpt4 key购买 nike

我正在使用 Python SQLAlchemy 运行一个 Restful API。我们在 AWS lambda 代理上运行无服务器,我遇到的问题是有时调用的任何 API 端点都会导致 504 HTTP Status Code .这不是一个特定的端点超时,它感觉非常随机,假设每 20 个 API 调用都会发生这种情况(非常奇特)。 API 网关的超时时间为 30 秒。
我正在将 Python 与 SQLAlchemy 和 PostgreSQL 数据库一起使用。挖掘日志,我发现了这个错误:

[WARNING] Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) 
after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol
(_ssl.c:1091)'))': /api/6261774/envelope/
504 出现时,这似乎一直在发生。发生错误。
非常感谢任何支持。
初步想法:
偶尔给它,它可能是网络连接失败?
预置并发确实运行初始化代码,我相信这是建立数据库连接的地方。是否值得尝试使用单个实例?

最佳答案

我建议在应用程序的所有层中打开调试并将日志推送到 Cloudwatch。接下来,您可以使用 Cloudwatch 日志洞察(有点像 Splunk)来查看错误的时间线以及导致错误的事件。
如果您是该服务的新手,这里有一篇关于 AWS Cloudwatch 日志见解的文章:
https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AnalyzingLogData.html
来自文章:

CloudWatch Logs Insights enables you to interactively search andanalyze your log data in Amazon CloudWatch Logs. You can performqueries to help you more efficiently and effectively respond tooperational issues. If an issue occurs, you can use CloudWatch LogsInsights to identify potential causes and validate deployed fixes.

CloudWatch Logs Insights includes a purpose-built query language witha few simple but powerful commands. CloudWatch Logs Insights providessample queries, command descriptions, query autocompletion, and logfield discovery to help you get started. Sample queries are includedfor several types of AWS service logs.

CloudWatch Logs Insights automatically discovers fields in logs fromAWS services such as Amazon Route 53, AWS Lambda, AWS CloudTrail, andAmazon VPC, and any application or custom log that emits log events asJSON.


这是一篇讨论将 PostgreSQL 日志发送到 Cloudwatch 的文章: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_LogAccess.Concepts.PostgreSQL.html
一般步骤是:
  • 选择您想要的数据库日志类型(查询失败、死锁、 fatal error 等)
  • 设置日志保留
  • 设置日志轮换
  • 设置日志目的地
  • 发送至 Cloudwatch
  • 关于 python "[WARNING] Retrying after connection broken by SSLError",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72541639/

    31 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com