Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email notification attempt results in "[Errno 99] Cannot assign requested address". #1423

Closed
1 of 3 tasks
devEricA-zz opened this issue Jul 26, 2019 · 8 comments
Closed
1 of 3 tasks
Labels

Comments

@devEricA-zz
Copy link

devEricA-zz commented Jul 26, 2019

Bug description
Whenever an email is attempted to be sent for a notification purpose, an alert pops up with this error.

Steps to reproduce

  1. Go to 'Notifications' (under Configuration tab)
  2. Check the 'Product Added' checkbox under the 'Mail' Column, and hit submit
  3. Click on the dropdown where it says 'Scope', change to 'Global', and repeat step 2.
  4. Click on 'System Settings' (under Configuration tab)
  5. Check the box where it says 'Enable Mail Notifications'
  6. Input one of your email addresses in the textbox where it says 'Mail Notifications to'.
  7. Click on submit
  8. Click on Add Product (under Products tab)
  9. Fill out all of the required fields, and hit submit.
  10. Notice that the alert count has gone up. One of them says "Notification Issue"
  11. Click on the alerts tab, then click "See All alerts"
  12. Observe the "Notification issue", description should read "[Errno 99] Cannot assign requested address"

Expected behavior
An email would be sent detailing the creation of a new product.

Deployment method (select with an X)

  • Kubernetes
  • Docker
  • setup.bash / legacy-setup.bash

Environment information

  • Operating System: Ubuntu 18.04
  • DefectDojo version: 98ccfa0: Tweaks for 1339 [2019-07-22 13:22:40 -0500]

Additional context (optional)
Discovered while working on an overhaul for Defectdojo's notifications. Unsure if a specific email address is supposed to go into the "Email Notifications from" field, or if there is something wrong with the functionality of the email notifications.

@devEricA-zz devEricA-zz changed the title Email notification attempt results in ([Errno 99] Cannot assign requested address). Email notification attempt results in "[Errno 99] Cannot assign requested address". Jul 29, 2019
@madchap
Copy link
Contributor

madchap commented Sep 10, 2019

So I didn't get that for the longest time, and now I do as well. That's on today's dev.

@madchap
Copy link
Contributor

madchap commented Sep 26, 2019

To reproduce, docker exec into the uwsgi container and run the following:

I have no name!@1a17c7a8976a:/app$ python
Python 3.5.7 (default, Jul 13 2019, 15:36:33) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from django.core.mail import send_mail
>>> from django.conf import settings
>>> settings.configure()
>>> send_mail('test','test msg','fred@xxxxx.net',['fred@yyyyy.com'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/site-packages/django/core/mail/__init__.py", line 60, in send_mail
    return mail.send()
  File "/usr/local/lib/python3.5/site-packages/django/core/mail/message.py", line 291, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/usr/local/lib/python3.5/site-packages/django/core/mail/backends/smtp.py", line 103, in send_messages
    new_conn_created = self.open()
  File "/usr/local/lib/python3.5/site-packages/django/core/mail/backends/smtp.py", line 63, in open
    self.connection = self.connection_class(self.host, self.port, **connection_params)
  File "/usr/local/lib/python3.5/smtplib.py", line 251, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/local/lib/python3.5/smtplib.py", line 336, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/local/lib/python3.5/smtplib.py", line 307, in _get_socket
    self.source_address)
  File "/usr/local/lib/python3.5/socket.py", line 712, in create_connection
    raise err
  File "/usr/local/lib/python3.5/socket.py", line 703, in create_connection
    sock.connect(sa)
OSError: [Errno 99] Cannot assign requested address

@madchap
Copy link
Contributor

madchap commented Sep 26, 2019

Another (and yes, the host running django sends email properly (i.e. I get daily O/S notifications), and is listening on 0.0.0.0:25)

I still need to restart the server (and hence this stack) to fully disable ipv6.. I guess it's known that sometimes this throws things off?

I have no name!@1a17c7a8976a:/app/dojo/settings$ python
Python 3.5.7 (default, Jul 13 2019, 15:36:33) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import smtplib
>>> server = smtplib.SMTP("localhost:25")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/smtplib.py", line 251, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/local/lib/python3.5/smtplib.py", line 336, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/local/lib/python3.5/smtplib.py", line 307, in _get_socket
    self.source_address)
  File "/usr/local/lib/python3.5/socket.py", line 712, in create_connection
    raise err
  File "/usr/local/lib/python3.5/socket.py", line 703, in create_connection
    sock.connect(sa)
OSError: [Errno 99] Cannot assign requested address

Using 127.0.0.1 has the same effect.

@madchap
Copy link
Contributor

madchap commented Sep 26, 2019

Disabled ipv6, stopped dojo, restarted docker daemon, restarted dojo, same thing.

@madchap
Copy link
Contributor

madchap commented Sep 26, 2019

I updated DD_EMAIL_URL to point to the IP address of the host as per the docker bridge interface (e.g. smtp://172.49.0.1:25).

From the container, I can connect and send an email using python console smptlib directly.

However, it still does not work using the dojo settings. Same error... or I am missing something?
I am missing something, no DD_* vars then.

@madchap
Copy link
Contributor

madchap commented Sep 26, 2019

OK, works better using python manage.py shell.. django n00b.

Of course, since the host changes and is not localhost anymore, don't forget to adjust your config to allow relaying.

Works now for me (tm).

@madchap
Copy link
Contributor

madchap commented Oct 7, 2019

So, not a bug I would say, configuration issue.

@madchap
Copy link
Contributor

madchap commented Dec 18, 2019

Closing here, no activity and likely in the end a configuration issue due to some change in docker -- at least, that's what happened to me.

Feel free to re-open @devEricA if you think I closed this wrongly.

Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants