Задать вопрос
@supet1337
Веб-разработчик

Ошибка на сервере took too long to shut down and was killed ( OSError: [Errno 99] Cannot assign requested address), как решить?

Есть вьюха, которая отправляет данные на почту. На локальном хосте(0.0.0.0) при debug=True и False работает хорошо, но на сервере почему-то всё сломалось и теперь она очень долго грузит и в итоге 500 ошибка.
И вот такое чудо:
Application instance wait_for=._call_check_cancel() at /usr/local/lib/python3.7/asyncio/futures.py:351, ()]>> for connection took too long to shut down and was killed.
Думал, что порт в докере закрыт, открыл его, но всё тщетно

Python:
def ask_question(request):
    if request.method == "POST":
        name = request.POST.get('name_ask')
        phone_number = request.POST.get('phone_ask')
        message = "Как зовут клиента: "+name+".\n" \
                    "Телефон клиента: " + phone_number
        send_mail(
            'Нужна консультация!', message, '...@gmail.com', [
                '...@gmail.com'], fail_silently=False)
        messages.info(request, "Вы успешно подали заявку. Проверьте почтовый ящик")
    return HttpResponseRedirect('/')

setting.py:
spoiler

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 465
ACCOUNT_EMAIL_VERIFICATION = "none"
EMAIL_HOST_USER = 'xxx@gmail.com'
EMAIL_HOST_PASSWORD = 'xxx'
DEFAULT_FROM_EMAIL = 'xxx@gmail.com'
EMAIL_USE_SSL = True

<form style="margin-right: 1em" class="appointment-form ftco-animate" method="POST" action="../ask_question">
                        {% csrf_token %}
                        <br>
                        <input type="text" style="border-bottom: 1px solid rgba(10, 10, 10, 0.2) !important;" id="name_ask" name="name_ask" class="form-control" pattern="[А-Яа-я]{2, 20}" required placeholder="Как вас зовут?">
                       <input type="tel" style="border-bottom: 1px solid rgba(10, 10, 10, 0.2) !important;" id="phone_ask" name="phone_teach" pattern="^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$" required class="form-control" placeholder="Телефон">
                        <input type="submit" style="margin-top: 10px;border-radius: 0;color: #082567;font-size: 20px;width: 100%" value="Хочу пообщаться" class="btn btn-primary">
                                <p style="margin-bottom: 0; font-size: 10px; text-align: center" >Нажимая, вы принимаете <b>условия соглашения</b></p>
                    </form>


Traceback:
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
web_1 | response = get_response(request)
web_1 | File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
web_1 | response = self.process_exception_by_middleware(e, request)
web_1 | File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
web_1 | response = wrapped_callback(request, *callback_args, **callback_kwargs)
web_1 | File "./talkapp/views.py", line 118, in send_request_view_teach
web_1 | user.email], fail_silently=False)
web_1 | File "/usr/local/lib/python3.7/site-packages/django/core/mail/__init__.py", line 60, in send_mail
web_1 | return mail.send()
web_1 | File "/usr/local/lib/python3.7/site-packages/django/core/mail/message.py", line 276, in send
web_1 | return self.get_connection(fail_silently).send_messages([self])
web_1 | File "/usr/local/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 102, in send_messages
web_1 | new_conn_created = self.open()
web_1 | File "/usr/local/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 62, in open
web_1 | self.connection = self.connection_class(self.host, self.port, **connection_params)
web_1 | File "/usr/local/lib/python3.7/smtplib.py", line 1031, in __init__
web_1 | source_address)
web_1 | File "/usr/local/lib/python3.7/smtplib.py", line 251, in __init__
web_1 | (code, msg) = self.connect(host, port)
web_1 | File "/usr/local/lib/python3.7/smtplib.py", line 336, in connect
web_1 | self.sock = self._get_socket(host, port, self.timeout)
web_1 | File "/usr/local/lib/python3.7/smtplib.py", line 1037, in _get_socket
web_1 | self.source_address)
web_1 | File "/usr/local/lib/python3.7/socket.py", line 728, in create_connection
web_1 | raise err
web_1 | File "/usr/local/lib/python3.7/socket.py", line 716, in create_connection
web_1 | sock.connect(sa)
web_1 | OSError: [Errno 99] Cannot assign requested address
  • Вопрос задан
  • 283 просмотра
Подписаться 1 Средний Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы