来自 Rancher 容器中 python 客户端的 smtp 超时
smtp timeout from python client in rancher container
我有一个奇怪的问题,不知道哪里出了问题,所以也许把它写在这里可以帮助我想出主意。或者有人可以帮助我:)
我在 rancher 中有一个 Django 站点 运行,过去几周我发现电子邮件无法正常工作。引发超时错误。我正在使用 mailgun.org 作为 SMTP 服务器。
这是 rancher 容器控制台的输出:
/app/app # ipython
Python 2.7.14 (default, Dec 19 2017, 22:36:09)
Type "copyright", "credits" or "license" for more information.
IPython 5.5.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: from smtplib import SMTP
In [2]: smtp = SMTP(host='smtp.mailgun.org', port=587)
它只是挂起。添加超时当然会引发超时。
我猜 mailgun 有问题。但是 运行 同一图像上的相同代码在本地有效(commit-hash
匹配 rancher 容器上的代码)。
docker run -ti registry.gitlab.com/namespace/app:commit-hash /bin/sh
/app/app # ipython
Python 2.7.14 (default, Dec 19 2017, 22:36:09)
Type "copyright", "credits" or "license" for more information.
IPython 5.5.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: from smtplib import SMTP
In [2]: smtp = SMTP(host='smtp.mailgun.org', port=587)
In [3]:
我不明白它是如何工作的。我联系了 mailgun 支持,询问他们是否阻止了我服务器的 ip 地址。他们的回答:
We are not blocking the production IP. The only way one environment
can work and not another is that there is some aspect of your two
environments that is different, so we would recommend reviewing the
configurations on your side.
如果我使用相同的 docker 图片,会有什么不同?我改变环境的唯一方法是环境变量,但其中 none 与 python/system.
有关
我还以为是我用 gevent 报错了,昨天删掉了。
Please try "telnet smtp.mailgun.org 587" in docker console
/app/app # telnet smtp.mailgun.org 587
telnet: can't connect to remote host (52.10.40.100): Operation timed out
/app/app #
Dockerfile 的第一行:
FROM python:2.7-alpine
ENV PYTHONUNBUFFERED 1
# Install dependencies
RUN apk update && \
apk add --no-cache build-base \
curl \
nano \
postgresql-dev \
vim
从主机远程登录:
~# telnet smtp.mailgun.org 587
Trying 34.232.180.42...
Trying 54.164.235.211...
Trying 34.237.7.101...
telnet: Unable to connect to remote host: Connection timed out
Hello,
In order to respond favorably to your request to unblock port 25 of your server, an additional verification is necessary.
...
看起来提供商 (Scaleway.com) 阻止了该端口。
当我使用外部电子邮件服务时,我不知道托管公司会这样做。无论如何,验证我的帐户,禁用阻止,硬重启服务器并且它有效。
谢谢大家comments/help!
我有一个奇怪的问题,不知道哪里出了问题,所以也许把它写在这里可以帮助我想出主意。或者有人可以帮助我:)
我在 rancher 中有一个 Django 站点 运行,过去几周我发现电子邮件无法正常工作。引发超时错误。我正在使用 mailgun.org 作为 SMTP 服务器。
这是 rancher 容器控制台的输出:
/app/app # ipython
Python 2.7.14 (default, Dec 19 2017, 22:36:09)
Type "copyright", "credits" or "license" for more information.
IPython 5.5.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: from smtplib import SMTP
In [2]: smtp = SMTP(host='smtp.mailgun.org', port=587)
它只是挂起。添加超时当然会引发超时。
我猜 mailgun 有问题。但是 运行 同一图像上的相同代码在本地有效(commit-hash
匹配 rancher 容器上的代码)。
docker run -ti registry.gitlab.com/namespace/app:commit-hash /bin/sh
/app/app # ipython
Python 2.7.14 (default, Dec 19 2017, 22:36:09)
Type "copyright", "credits" or "license" for more information.
IPython 5.5.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: from smtplib import SMTP
In [2]: smtp = SMTP(host='smtp.mailgun.org', port=587)
In [3]:
我不明白它是如何工作的。我联系了 mailgun 支持,询问他们是否阻止了我服务器的 ip 地址。他们的回答:
We are not blocking the production IP. The only way one environment can work and not another is that there is some aspect of your two environments that is different, so we would recommend reviewing the configurations on your side.
如果我使用相同的 docker 图片,会有什么不同?我改变环境的唯一方法是环境变量,但其中 none 与 python/system.
有关我还以为是我用 gevent 报错了,昨天删掉了。
Please try "telnet smtp.mailgun.org 587" in docker console
/app/app # telnet smtp.mailgun.org 587
telnet: can't connect to remote host (52.10.40.100): Operation timed out
/app/app #
Dockerfile 的第一行:
FROM python:2.7-alpine
ENV PYTHONUNBUFFERED 1
# Install dependencies
RUN apk update && \
apk add --no-cache build-base \
curl \
nano \
postgresql-dev \
vim
从主机远程登录:
~# telnet smtp.mailgun.org 587
Trying 34.232.180.42...
Trying 54.164.235.211...
Trying 34.237.7.101...
telnet: Unable to connect to remote host: Connection timed out
Hello,
In order to respond favorably to your request to unblock port 25 of your server, an additional verification is necessary. ...
看起来提供商 (Scaleway.com) 阻止了该端口。
当我使用外部电子邮件服务时,我不知道托管公司会这样做。无论如何,验证我的帐户,禁用阻止,硬重启服务器并且它有效。
谢谢大家comments/help!