docker – 来自牧场主容器中python客户端的smtp超时

前端之家收集整理的这篇文章主要介绍了docker – 来自牧场主容器中python客户端的smtp超时前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我有一个奇怪的问题,没有想法可能是错的,所以也许在这里写它可以帮助我提出想法.或者有人可以帮助我:)

我有一个在牧场主运行的Django网站,过去几周我发现电子邮件无法正常工作.超时错误被提出.我使用mailgun.org作为SMTP服务器.

这是从牧场主容器控制台输出的:

/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,port=587)

In [3]:

我不知道它是如何工作的.如果他们阻止我的服务器的IP地址,我联系了mailgun支持.他们的回答:

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.

如果我使用相同的泊坞窗图像会有什么不同?我改变环境的唯一方法是env变量,但它们都不与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:

~# 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)阻止了该端口.

当我使用外部服务收发电子邮件时,我不知道托管公司正在这样做.无论如何,验证我的帐户,禁用阻止,硬重启服务器,它的工作原理.

谢谢大家的意见/帮助!

原文链接:https://www.f2er.com/docker/436627.html

猜你在找的Docker相关文章