Read time out error when attempting to send from Bamboo on EC2 using Amazon SES

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Problem

When using Bamboo in EC2, one mail server option is Amazon's Simple Email Service (SES).

When trying to send an email (eg: notification) from Bamboo, your emails fail to send, and the following "Read time out" error appears in the atlassian-bamboo.log

Caused by: javax.mail.MessagingException: Exception reading response;
nested exception is:
java.net.SocketTimeoutException: Read timed out
at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2304)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2031)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:697)
at javax.mail.Service.connect(Service.java:364)
at javax.mail.Service.connect(Service.java:245)
at javax.mail.Service.connect(Service.java:194)
at com.atlassian.mail.server.impl.SMTPMailServerImpl.sendWithMessageId(SMTPMailServerImpl.java:174)
... 289 more
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:150)
at java.net.SocketInputStream.read(SocketInputStream.java:121)
at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:124)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
at java.io.BufferedInputStream.read(BufferedInputStream.java:265)
at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:89)
at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:2284)
... 295 more

Diagnosis

Environment

  • Bamboo on Unix-based Amazon EC2 instance

Diagnostic Steps

  • Telnet to the mail server to ensure that the connection is open. For example, if you are connecting to email-smtp.us-east-1.amazonaws.com over TLS:

    telnet email-smtp.us-east-1.amazonaws.com 465
    Trying 23.21.89.230...
    Connected to email-smtp.us-east-1.amazonaws.com.
    Escape character is '^]'.

    Please note that the IP above may change since Amazon uses dynamic IPs for SES servers.

  • Check the network interfaces for their MTU values:

    ip link show

    One of the rows of output should contain this string: <BROADCAST,MULTICAST,UP,LOWER_UP>. If this row contains mtu 9001 your EC2 instance is sending "jumbo packets" which may be too large.

Cause

The Amazon AWS documentation page Amazon SES SMTP Issues suggests that:

If you receive a time-out error message, the maximum transmission unit (MTU) size on the network interface of the computer you're using to connect to the Amazon SES SMTP interface might be too large. 

Resolution

To resolve this, we can set the MTU to 1500 packets which is recommended for internet traffic, according to Amazon documentation.

In this example we will be using eth0, but please make sure you are using your network interface from the output of ip link show.

  1. SSH to your EC2 instance
  2. Run the following command:

    sudo ip link set dev eth0 mtu 1500

    changing eth0 to your network interface label.

  3. (Optional) To persist your network MTU setting after a reboot, modify the following configuration files, based on your operating system type. This procedure covers Amazon Linux and Ubuntu; for other distributions, consult their specific documentation.

    • For Amazon Linux, add the following lines to your /etc/dhcp/dhclient-eth0.conf file.

      interface "eth0" {
      supersede interface-mtu 1500;
      }
    • For Ubuntu, add the following line to /etc/network/interfaces.d/eth0.cfg.

      post-up /sbin/ifconfig eth0 mtu 1500
  4. (Optional) Reboot your instance and verify that the MTU setting is correct.


See also


Last modified on Jun 1, 2018

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.