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
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
first lines of the Docker file:
FROM python:2.7-alpine ENV PYTHONUNBUFFERED 1
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