eclipse-vertx / eclipse-vertx/vert.x
WebSocket Client Connection Evicted/Shutdown During Handshake in Vert.x 5.0.5
- Dominant language
- Java
- Stars
- 14.7k
- Forks
- 2.1k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 28
Description
### Version
5.0.5
### Context
## 🐛 Bug Report: Intermittent WebSocket Client Connection Eviction/Shutdown During Handshake
### 🎯 Version
* **Vert.x Version:** 5.0.5
* **Operating System:** macOS (Apple Silicon - M1)
* **Java:** 21
Java Version: OpenJDK 21
### 📝 Description
I'm encountering an issue where the **WebSocket client connection is being unexpectedly shut down (`ShutdownEvent` / `Connection evicted`) immediately after sending the WebSocket handshake request, and before receiving the server's handshake response. This issue occurs **intermittently (occasionally)**, not on every attempt, but when it does, it prevents the WebSocket connection from being established. The client is connecting to a locally developed Vert.x WebSocket server.
### ✅ Expected Behavior
The WebSocket client should wait for the server's handshake response. If the response is valid, the connection should be upgraded to a WebSocket connection and stay active. The connection should not be shut down or evicted during the handshake phase unless explicitly requested or due to a network error/timeout.
### ❌ Actual Behavior
**Intermittently**, the connection is closed/evicted during the handshake phase, specifically after the handshake request is sent and before a response is received.
The log shows a `USER_EVENT: io.vertx.core.net.impl.ShutdownEvent` which leads to a `Connection evicted` warning and subsequent connection closure, as shown below:
```log
... (Handshake Request WRITE/FLUSH occurs before this)
2025-12-05 16:25:21 DEBUG [vert.x-eventloop-thread-2] i.n.handler.logging.LoggingHandler - [id: 0xe82a509f, L:/127.0.0.1:55615 - R:localhost/127.0.0.1:47136] ACTIVE
2025-12-05 16:25:21 DEBUG [vert.x-eventloop-thread-2] i.n.handler.logging.LoggingHandler - [id: 0xbe1d97b4, L:/127.0.0.1:55615 - R:localhost/127.0.0.1:47136] USER_EVENT: io.vertx.core.net.impl.ShutdownEvent@4909845e
2025-12-05 16:25:21 WARN [vert.x-eventloop-thread-2] i.v.c.h.i.HttpClientConnectionInternal - Connection evicted
2025-12-05 16:25:21 DEBUG [vert.x-eventloop-thread-2] i.n.handler.logging.LoggingHandler - [id: 0xbe1d97b4, L:/127.0.0.1:55615 - R:localhost/127.0.0.1:47136] WRITE: 0B
2025-12-05 16:25:21 DEBUG [vert.x-eventloop-thread-2] i.n.handler.logging.LoggingHandler - [id: 0xbe1d97b4, L:/127.0.0.1:55615 - R:localhost/127.0.0.1:47136] FLUSH
2025-12-05 16:25:21 DEBUG [vert.x-eventloop-thread-2] i.n.handler.logging.LoggingHandler - [id: 0xbe1d97b4, L:/127.0.0.1:55615 - R:localhost/127.0.0.1:47136] CLOSE
2025-12-05 16:25:21 DEBUG [vert.x-eventloop-thread-2] i.n.handler.logging.LoggingHandler - [id: 0xbe1d97b4, L:/127.0.0.1:55615 ! R:localhost/127.0.0.1:47136] INACTIVE
```
### Steps to reproduce
1. Create Http Server with webSocketHandshakeHandler, webSocketHandler
2. Use the `WebSocketClient` to initiate a WebSocket connection.
3. The client sends the WebSocket handshake `GET` request.
4. Immediately following the write/flush of the handshake request, a `ShutdownEvent` is processed on the connection, leading to an eviction.
### Do you have a reproducer?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.