Python client smtp timeout in ranch container

I have a strange problem, I have no idea what might be wrong, so maybe writing it here will help me come up with ideas. Or someone can help me :)

I have a ranch-based Django site, and over the past few weeks I have noticed that emails do not work. Timeout error. I use mailgun.org as an SMTP server.

This is displayed from the console of the runzer container:

/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 features. %quickref -> Quick reference. help -> Python 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) 

And it just freezes. Adding a timeout increases the latency.

I would suggest that something is wrong with mailgun. But the same code works on the same image locally ( commit-hash matches that on the ranch container).

 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 features. %quickref -> Quick reference. help -> Python 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]: 

I do not understand how this works. I contacted mailgun support with the question of whether I am blocking my server ip address. Their answer:

We do not block the production IP address. The only way to one environment can work, and not that there are some aspects of your two that are different from each other, so we recommend that you review the configuration on your side.

What could be different if I use the same docker image? The only way to change the environment is with env variables, but none of them are related to python / system.

I thought the error was overlaid by me with gevent, but yesterday I deleted it.


Try "telnet smtp.mailgun.org 587" in the dock console

 /app/app # telnet smtp.mailgun.org 587 telnet: can't connect to remote host (52.10.40.100): Operation timed out /app/app # 

first lines of the Docker file:

 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 from the host computer:

 ~# 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 
+8
docker smtplib mailgun rancher
source share
1 answer

Hello,

To respond to your request to unlock port 25 of your server, an additional check is required ....

It seems that the provider (Scaleway.com) has blocked this port.

I had no idea that hosting companies do this when I use an external email service. In any case, check my account, a locked lock, a restarted server, and it works.

Thank you all for your comments / help!

+3
source share

All Articles