---
title: "Watch a client fail over"
description: "Kill a broker on the Kafka Simulator canvas while a real producer and consumer run through monedula-sim-bridge, and watch them move to the new leaders."
url: https://monedula.dev/flock/docs/sim-bridge/how-to/watch-a-client-fail-over/
---
The bridge opens one Kafka listener per simulated broker and closes it when that broker dies. So killing a broker on the canvas does to a real client what a broker crash does: its connections drop, its requests to the dead broker fail with retriable errors, it refreshes its metadata and carries on against the new leaders.

## Before you start

- A paired bridge, from steps 1 and 2 of [Connect your first app](/flock/docs/sim-bridge/tutorials/connect-your-first-app/).
- A topic with replication factor 3, such as `clicks` from [Create topics](/flock/docs/sim-bridge/how-to/create-topics/).

## Steps

### 1. Start a producer and a consumer

Keep both running in their own terminals:

```bash
bin/kafka-producer-perf-test.sh --topic clicks --num-records 100000 \
  --throughput 20 --record-size 32 \
  --producer-props bootstrap.servers=127.0.0.1:19092
```

```bash
bin/kafka-console-consumer.sh --bootstrap-server 127.0.0.1:19092 \
  --topic clicks --group clicks-readers
```

`--throughput 20` keeps the producer under the playground's 200 records a second per app, so it is not throttled.

### 2. Kill a broker

Select `broker-1` on the canvas, then **kill · hard broker-1**. The partitions it led elect new leaders from their in-sync replicas, and the bridge closes the port of `broker-1`.

Watch the clients:

- The producer's requests to the old leader fail with a retriable error, `NOT_LEADER_OR_FOLLOWER` or a dropped connection, so it fetches new metadata and sends to the new leader. With the default idempotent producer, a batch that was retried is written once.
- The consumer's fetches from the old leader fail the same way, and it fetches from the new leader where it left off.

### 3. When the broker was the group coordinator

The playground picks the coordinator of a group from its group id and the live brokers, so the broker you killed may have coordinated `clicks-readers`. If it did, the coordinator moves to another live broker, the members get `NOT_COORDINATOR`, look the coordinator up again and stay in the group. We tested this with the Java consumer: it keeps consuming without losing its group. Kill and restart other brokers one at a time to hit the coordinator if the first was not it.

### 4. Bring the broker back

Select `broker-1`, then **restart broker-1**. Its port opens again, and the clients use it once their next metadata refresh lists it.

## Why the client sees real errors

Each simulated broker has its own port: broker 1 on 19092, broker 2 on 19093, and so on. A request reaches the broker the client chose, and the playground answers as that broker would: a broker that does not lead the partition says so, and a dead broker has no port at all. See [How it works](/flock/docs/sim-bridge/concepts/how-it-works/) and [Error codes](/flock/docs/sim-bridge/reference/error-codes/).

<Callout type="tip" title="Bootstrap from more than one broker">

Killing `broker-1` closes port 19092, the usual bootstrap address. A running client does not need it any more, but a client that starts while `broker-1` is dead does. Give clients more than one address, such as `bootstrap.servers=127.0.0.1:19092,127.0.0.1:19093`.

</Callout>