Search code examples
mysqlapache-kafkadocker-composeapache-kafka-connectdebezium

Debezium Connector - Communication link failure


i got issue when connect local mysql using docker

{"error_code":400,"message":"Connector configuration is invalid and contains the following 1 error(s):\nUnable to connect: Communications link failure\n\nThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.\nYou can also find the above list of errors at the endpoint /connector-plugins/{connectorType}/config/validate"}

here my configuration :

 {
  "name": "inventory-connector",
  "config": {
    "connector.class": "io.debezium.connector.mysql.MySqlConnector",
    "tasks.max": "1",
    "database.hostname": "mysql",
    "database.port": "3306",
    "database.user": "debezium",
    "database.password": "dbz",
    "database.server.id": "184054",
    "database.server.name": "dbserver1",
    "database.include.list": "inventory",
    "database.allowPublicKeyRetrieval":"true",
    "database.history.kafka.bootstrap.servers": "kafka:9092",
    "database.history.kafka.topic": "schema-changes.inventory"
  }
}

this my mysql docker-compose.yaml

version: '3.3'

services:
  mysql:
    image: quay.io/debezium/example-mysql:1.9
    container_name: mysql
    environment:
      - MYSQL_USER=mysqluser
      - MYSQL_PASSWORD=mysqlpw
      - MYSQL_ROOT_PASSWORD=debezium
    volumes:
      - ./mysqldb_data:/var/lib/mysql
    ports:
      - 3306:3306

networks:
  zookeeper_default:
    external:
      name: zookeeper_default

let me know if you know anything, thanks


Solution

  • "database.hostname": "mysql"

    If you're running Debezium outside of Docker, you should be using localhost here, and similarly for database.history.kafka.bootstrap.servers.

    Otherwise, you need to ensure that the Debezium server and mysql are attached to same Docker network. Use docker network and docker inspect commands to debug this, and exec into both containers and try to ping in the both directions using their service names