4

I've been getting the above error when using two servers to connect to the same Aurora DB.

We're running a simple Django REST Framework on Elastic Beanstalk which connects to an Aurora DB cluster. Whenever we start up the DB and test the API from the EBS server connections go through fine. However, if I then start up my local development server connecting to the same DB, I get the operational error when going to the same route on the local server.

  • I've tried increasing 'connect_time', 'interactive_timeout', 'max_execution_time', 'wait_timeout', 'max_allowed_packet', and 'max_user_connections' in increments up to the max. No change.
  • The query shouldn't be big as there's only about 20 items in the table, and most of the time we're querying one item.
  • We aren't managing the connection manually anywhere so it's not that we accidentally closed the connection prematurely.
  • I've dug through the MySQL logs and only found the following message:

    Aborted connection ## to db: 'db_name' user: 'username' host: 'host_ip' (Got an error reading communication packets). Which seems to be pretty generic, and implies something on the dev server is closing the connection.

  • The only way to get the development server to stop throwing this exception is to reboot the Aurora DB.
  • Django Database settings have the CONN_MAX_AGE set to 0 which makes the most sense to me.
  • I created a new Aurora DB instance with fresh migrations and one entry in the table, with the same issues.

In addition if I open the Django shell and run a simple query with the models, the Beanstalk server will then start throwing InterfaceError(0, ''). Again this remains until the Aurora DB is rebooted.

I've dug through a number of sources but haven't found a fix yet. Anyone else have some ideas?

Version Info

  • Django == 2.1.5
  • Django REST Framework == 3.9.1
  • MySQL Compatibility Engine == 5.7.12
user2659205
  • 157
  • 1
  • 1
  • 7

1 Answers1

1

You can try use the MySQL connector PyMySQL==0.7.9

Zoe
  • 27,060
  • 21
  • 118
  • 148