1

Im running an application running React, python and MySQL with a docker compose, When I run the application everything works fine, but when a pettition to the database (from the frontend with axios) is made multiple times, the connection breaks and the following error appears. Everything is running locally

"2055: Lost connection to MySQL server at 'database:3306', system error: 8 EOF occurred in violation of protocol (_ssl.c:2483)"

Here is the configuration of my connection and my dockerfile


    import mysql.connector


    return mysql.connector.connect(
    host=os.environ.get("database"),
    user="root",
    password="root",
    database="locatec",
    port=3306,
    auth_plugin='mysql_native_password'
    )
  database:
      image: mysql
      container_name: database
      restart: always
      ports:
        - '3306:3306'
      #command: --init-file /init.sql
      volumes:
        - ./init.sql:/docker-entrypoint-initdb.d/init.sql
        - ~/apps/mysql:/var/lib/locatec5
      environment:
        MYSQL_ROOT_PASSWORD: root
        MYSQL_USER: test
        MYSQL_PASSWORD: test
        MYSQL_ROOT_HOST: '%'
        TIMEZONE: UTC

      networks:
        - locatec

  server:
    build: 
      context: ../../../
      dockerfile: infra/deploy/backend/dev/Dockerfile
    restart: always
    ports:
      - "5000:5000"
    container_name: server
    networks:
      - locatec
    depends_on:
      - database

I tried using

mysql-connector-python==8.0.30

, also I configured the param of ssl to false

5
  • Could try 8.0.31, but its release notes don't list a fix. So this looks like a bug that would be beneficial to report. Commented Nov 12, 2022 at 22:34
  • Is the server container crashing that caused the this? The /var/lib/locatec5 looks odd and no /var/lib/mysql mount point. Commented Nov 12, 2022 at 23:45
  • Nothing looks crashed on docker, only the message appears and all connections are lost Commented Nov 15, 2022 at 4:05
  • If everything is running locally, why does it need SSL? Commented Nov 15, 2022 at 4:10
  • Nothing is using SSL, the only thing that requires SSL is Auth0 that we are using on the frontend Commented Nov 15, 2022 at 4:20

1 Answer 1

2
+50

This looks like an error I faced some time ago. In my case, it was due to a client initiating a secured connection to a non-secured server.

The error message indicates that the client has initiated a SSL/TLS connection and is expecting to receive more data than the server has sent during the handshake procedure.

There are two ways to fix this, either by:

  • enabling SSL/TLS on server side so that the client can initiate a SSL/TLS handshake and get a consistent response. [Docker side]
  • disabling the SSL/TLS from the database connector. [Python side]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.