Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Synapse fails to send email on IPv6 only networks #12532

Closed
telmich opened this issue Apr 22, 2022 · 2 comments
Closed

Synapse fails to send email on IPv6 only networks #12532

telmich opened this issue Apr 22, 2022 · 2 comments

Comments

@telmich
Copy link

telmich commented Apr 22, 2022

Description

When Synapse is deployed in an IPv6 only environment and resolves the email.smtp_host value via DNS, it only connects to IPv4.
The DNS record in question (smtp.ungleich.ch) has both, AAAA and A entries, however synapse/twisted, don't try the AAAA entry, not even at a later stage.

The error message is:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/synapse/handlers/identity.py", line 412, in send_threepid_validation                                                       
    await send_email_func(email_address, token, client_secret, session_id)
  File "/usr/local/lib/python3.9/site-packages/synapse/push/mailer.py", line 179, in send_registration_mail                                                               
    await self.send_email(
  File "/usr/local/lib/python3.9/site-packages/synapse/push/mailer.py", line 325, in send_email                                                                           
    await self.send_email_handler.send_email(
  File "/usr/local/lib/python3.9/site-packages/synapse/handlers/send_email.py", line 180, in send_email                                                                   
    await self._sendmail(
  File "/usr/local/lib/python3.9/site-packages/synapse/handlers/send_email.py", line 116, in _sendmail                                                                    
    await make_deferred_yieldable(d)
twisted.internet.error.NoRouteError: No route to host: 101: Network is unreachable.

Steps to reproduce

  • deploy matrix in an IPv6 only environment (f.i. ipv6 only kubernetes cluster)
  • Configure synapse to send emails via a mailserver that has both AAAA and A DNS entries

Suggested fix

Synapse should

  • get both AAAA and A entries
  • try all records in parallel
  • Use the first connection that works

(standard happy eyeballs algorithm)

Further information

  • This problem is a blocker, as it is impossible to specifiy the IPv6 address of the mail server directly
  • If the IPv6 address is specified directly, the following error happens which indicates an SSL error:
    2022-04-22 22:01:15,959 - synapse.handlers.identity - 414 - ERROR - POST-18- Error sending threepid validation email to ...@ungleich.ch
    Traceback (most recent call last):
      File "/usr/local/lib/python3.9/site-packages/synapse/handlers/identity.py", line 412, in send_threepid_validation
        await send_email_func(email_address, token, client_secret, session_id)
      File "/usr/local/lib/python3.9/site-packages/synapse/push/mailer.py", line 179, in send_registration_mail
        await self.send_email(
      File "/usr/local/lib/python3.9/site-packages/synapse/push/mailer.py", line 325, in send_email
        await self.send_email_handler.send_email(
      File "/usr/local/lib/python3.9/site-packages/synapse/handlers/send_email.py", line 180, in send_email
        await self._sendmail(
      File "/usr/local/lib/python3.9/site-packages/synapse/handlers/send_email.py", line 116, in _sendmail
        await make_deferred_yieldable(d)
    twisted.internet.error.ConnectionAborted: Connection was aborted locally using ITCPTransport.abortConnection.

Version information

  • Synapse 1.57.1
  • Homeserver: ANY

If not matrix.org:

  • Version: 1.57.1

  • Install method: docker/kubernetes

  • Platform: kubernetes

@richvdh
Copy link
Member

richvdh commented Apr 24, 2022

dup #7720 I think

@richvdh richvdh closed this as completed Apr 24, 2022
@telmich
Copy link
Author

telmich commented Apr 24, 2022

Thank for spotting it, @richvdh!

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

No branches or pull requests

2 participants