所以,我有一个安装在GCP上的微服务基础设施,它是用Python,FastAPI和它的dockerized。我通过HTTP请求在这些API(大约7个API)之间进行通信。3周前,一个错误开始出现,而我没有接触任何代码。
这是Shipping API -> E-CommerceCommunication API之间的通信。
这是开始发生的错误。
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='anyurl', port=443): Max retries exceeded with url: /anyEndpoint (Caused by SSLError(SSLEOFError(8, '[SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1002)')))
奇怪的是,这发生在Shipping API上,在它生成指南(这是一个HTTP请求)之后。
因此,工作流程是下一个:生成指南(HTTP请求)->生成指南的PDF(HTTP请求)->将运输信息发送到电子商务(HTTP请求)。这就是它失败的地方)。
这是我的dockerfile
FROM python:3.11-slim-bookworm
COPY . .
ENV PYTHONUNBUFFERED=1
RUN pip install -r requirements.txt
CMD exec gunicorn --bind :$PORT --workers 4 --worker-class uvicorn.workers.UvicornWorker --timeout 3600 Main:app
这是我的需求文件。
-i https://pypi.org/simple
anyio==3.7.0 ; python_version >= '3.7'
cachetools==5.3.1 ; python_version >= '3.7'
certifi==2023.5.7 ; python_version >= '3.6'
charset-normalizer==3.1.0 ; python_full_version >= '3.7.0'
click==8.1.3 ; python_version >= '3.7'
colorama==0.4.6 ; platform_system == 'Windows'
fastapi==0.99.1
fuzzywuzzy==0.18.0
google-api-core==2.11.1 ; python_version >= '3.7'
google-auth==2.21.0 ; python_version >= '3.6'
google-cloud-core==2.3.2 ; python_version >= '3.7'
google-cloud-storage==2.10.0
google-crc32c==1.5.0 ; python_version >= '3.7'
google-resumable-media==2.5.0 ; python_version >= '3.7'
googleapis-common-protos==1.59.1 ; python_version >= '3.7'
greenlet==2.0.2 ; platform_machine == 'aarch64' or (platform_machine == 'ppc64le' or (platform_machine == 'x86_64' or (platform_machine == 'amd64' or (platform_machine == 'AMD64' or (platform_machine == 'win32' or platform_machine == 'WIN32')))))
gunicorn==20.1.0
h11==0.14.0 ; python_version >= '3.7'
idna==3.4 ; python_version >= '3.5'
levenshtein==0.21.1
numpy==1.25.0 ; python_version >= '3.10'
pandas==2.0.3
protobuf==4.23.3 ; python_version >= '3.7'
pyasn1==0.5.0 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
pyasn1-modules==0.3.0 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
pydantic==1.10.10 ; python_version >= '3.7'
pymysql==1.1.0
pypdf==3.12.0
python-dateutil==2.8.2 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
python-dotenv==1.0.0
python-multipart==0.0.6
pytz==2023.3
rapidfuzz==3.1.1 ; python_version >= '3.7'
requests==2.31.0 ; python_version >= '3.7'
rsa==4.9 ; python_version >= '3.6' and python_version < '4'
setuptools==68.0.0 ; python_version >= '3.7'
six==1.16.0 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
sniffio==1.3.0 ; python_version >= '3.7'
sqlalchemy==2.0.17
starlette==0.27.0 ; python_version >= '3.7'
suds==1.1.2
typing-extensions==4.7.1 ; python_version >= '3.7'
tzdata==2023.3 ; python_version >= '2'
urllib3==1.26.16 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
uvicorn==0.22.0
这是来自Shipping API -> E-CommerceComm-API的请求
from Models.PydanticSchemes.GuidesScheme import DbGuides
import requests
class ECommerceCommunicationsAPI():
@staticmethod
def UpdateOrders(Orders: list[DbGuides]):
URL = "https://myurl.com/updateOrders"
payload = []
for order in Orders:
tracking_urls = {
"Domina" : f"https://oriontracking.infokairos.com.co/envios/{order.GuideNumber}/tracking/cliente",
"E-Box" : f"https://enviexpresslogistica.com/tracking/result/?NoGuia={order.GuideNumber}",
"Coordinadora" : f"https://www.coordinadora.com/portafolio-de-servicios/servicios-en-linea/rastrear-guias/?guia={order.GuideNumber}"
}
orderJson = {
"OrderNumber" : order.OrderNumber,
"GuideNumber" : order.GuideNumber,
"Company" : order.Company,
"Tracking_URL" : tracking_urls[order.Company]
}
payload.append(orderJson)
response = requests.post(URL, json = payload, verify = False) # Remove verif
我把我的docker python镜像改成了Python:3,但把它改成了实际的。删除所有要求并重新安装Uninstalled pyopenssl尝试将容器推送到新的Google示例。
上面的都不管用。
1条答案
按热度按时间toe950271#
我受到了这个相同错误的影响,设置几乎相同,从
requests
切换到httpx
对我来说很有效。我仍然不能100%确定为什么这工作,但改变requests.post
到httpx.post
可能解决错误。