establishing connection with smtp.gmail.com is failing resulting in timeout error in Django project when i am behind proxy server (gateway)

19 views
Skip to first unread message

Maha Alwoheby

unread,
Feb 25, 2020, 3:17:26 PM2/25/20
to The Nadine Project
i know that this is not a nadine in specific issue but i havent found solutions for this
in my company i was asked to install nadine to manage the coworking space in the company

the issue is that my django app that i run locally on my company pc is not sending any emails through smtp.gmail.com. i finally figured that my app is not connecting with the gmail smtp server at all and at the end result in timeout error.

i tested this on machines that are connected to the internet directly without a server gateway and everything works perfectly. however on my work machine it doesn't.

when i use trace command : sudo traceroute -n -T -p 25 gmail-smtp-in.l.google.com

it results in:


traceroute to gmail-smtp-in.l.google.com (108.177.15.26), 30 hops max, 60 byte packets 1 * * * 2 * * * 3 * * * 4 * * * 5 * * * 6 * * * 7 * * * 8 * * * 9 * * * 10 * * * 11 * * * 12 * * * 13 * * * 14 * * * 15 * * * 16 * * * 17 * * * 18 * * * 19 * * * 20 * * * 21 * * * 22 * * * 23 * * * 24 * * * 25 * * * 26 * * * 27 * * * 28 * * * 29 * * * 30 * * *

i asked the network admin if the firewall of the proxy server is blocking SYN packets but im not sure if this is from him or from what exactly i read some recommendation that i should use PySocket but i have no idea where or how to implement that in the django project file.


is there anyway i can tell my django that i'm behind proxy and to establish the connection through such proxy?


traceback of creating a new user:


Traceback (most recent call last):
  File "/home/maha/nadine/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/maha/nadine/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/maha/nadine/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/maha/nadine/lib/python3.7/site-packages/django/contrib/admin/options.py", line 607, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "/home/maha/nadine/lib/python3.7/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/home/maha/nadine/lib/python3.7/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/home/maha/nadine/lib/python3.7/site-packages/django/contrib/admin/sites.py", line 231, in inner
    return view(request, *args, **kwargs)
  File "/home/maha/nadine/lib/python3.7/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/home/maha/nadine/lib/python3.7/site-packages/django/views/decorators/debug.py", line 76, in sensitive_post_parameters_wrapper
    return view(request, *args, **kwargs)
  File "/home/maha/nadine/lib/python3.7/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/home/maha/nadine/lib/python3.7/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/home/maha/nadine/lib/python3.7/site-packages/django/contrib/auth/admin.py", line 99, in add_view
    return self._add_view(request, form_url, extra_context)
  File "/home/maha/nadine/lib/python3.7/site-packages/django/contrib/auth/admin.py", line 126, in _add_view
    return super().add_view(request, form_url, extra_context)
  File "/home/maha/nadine/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1638, in add_view
    return self.changeform_view(request, None, form_url, extra_context)
  File "/home/maha/nadine/lib/python3.7/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/home/maha/nadine/lib/python3.7/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/home/maha/nadine/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1522, in changeform_view
    return self._changeform_view(request, object_id, form_url, extra_context)
  File "/home/maha/nadine/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1565, in _changeform_view
    self.save_model(request, new_object, form, not add)
  File "/home/maha/nadine/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1081, in save_model
    obj.save()
  File "/home/maha/nadine/lib/python3.7/site-packages/django/contrib/auth/base_user.py", line 66, in save
    super().save(*args, **kwargs)
  File "/home/maha/nadine/lib/python3.7/site-packages/django/db/models/base.py", line 746, in save
    force_update=force_update, update_fields=update_fields)
  File "/home/maha/nadine/lib/python3.7/site-packages/django/db/models/base.py", line 795, in save_base
    update_fields=update_fields, raw=raw, using=using,
  File "/home/maha/nadine/lib/python3.7/site-packages/django/dispatch/dispatcher.py", line 175, in send
    for receiver in self._live_receivers(sender)
  File "/home/maha/nadine/lib/python3.7/site-packages/django/dispatch/dispatcher.py", line 175, in <listcomp>
    for receiver in self._live_receivers(sender)
  File "/home/maha/nadine/nadine/nadine/models/profile.py", line 913, in sync_primary_callback
    email_address.save(verify=False)
  File "/home/maha/nadine/nadine/nadine/models/profile.py", line 720, in save
    self.generate_verif_key()
  File "/home/maha/nadine/nadine/nadine/models/profile.py", line 692, in generate_verif_key
    self.save()
  File "/home/maha/nadine/nadine/nadine/models/profile.py", line 728, in save
    email.send_verification(self)
  File "/home/maha/nadine/nadine/nadine/email.py", line 86, in send_verification
    send_email(emailObj.email, subject, text_msg, html_msg)
  File "/home/maha/nadine/nadine/nadine/email.py", line 381, in send_email
    msg.send(fail_silently=False)
  File "/home/maha/nadine/lib/python3.7/site-packages/django/core/mail/message.py", line 276, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/home/maha/nadine/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 102, in send_messages
    new_conn_created = self.open()
  File "/home/maha/nadine/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 62, in open
    self.connection = self.connection_class(self.host, self.port, **connection_params)
  File "/usr/lib/python3.7/smtplib.py", line 251, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib/python3.7/smtplib.py", line 336, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib/python3.7/smtplib.py", line 307, in _get_socket
    self.source_address)
  File "/usr/lib/python3.7/socket.py", line 727, in create_connection
    raise err
  File "/usr/lib/python3.7/socket.py", line 716, in create_connection
    sock.connect(sa)

Jacob Sayles

unread,
Feb 25, 2020, 3:20:47 PM2/25/20
to The Nadine Project
Google locks down their mail client so it’s tricky getting it to work as an SMTP service.  They make you enable “Less secure app access” to even allow it in the first place.  If you can, I’d suggest using a better service such as fastmail.  

Jacob Sayles
Technical Director
--
You received this message because you are subscribed to the Google Groups "The Nadine Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nadineprojec...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nadineproject/d2a08c4a-5732-4058-aa4d-ed532f3ba0ca%40googlegroups.com.

Maha Alwoheby

unread,
Feb 27, 2020, 4:43:48 PM2/27/20
to The Nadine Project
i have enabled the option "Less secure app access" , it is not the issue with google themselves since nadine works perfectly on my laptop at home, because i have direct access to the internet. but my machine in the office is behind a gateway server which is causing the whole issue.


On Tuesday, February 25, 2020 at 11:20:47 PM UTC+3, Jacob Sayles wrote:
Google locks down their mail client so it’s tricky getting it to work as an SMTP service.  They make you enable “Less secure app access” to even allow it in the first place.  If you can, I’d suggest using a better service such as fastmail.  

Jacob Sayles
Technical Director
To unsubscribe from this group and stop receiving emails from it, send an email to nadine...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages