ktorio / ktorio/ktor

Can't close WebSocketSession with Netty/Jetty engine

Open
#1,074 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
14.5k
Forks
1.3k
Avg merge
2d 13h
Merged PRs (30d)
49

Description

### Ktor Version
1.1.3 & 1.1.4

### Ktor Engine Used (client or server and name)
The issue is only about a server.
`Netty`, `Jetty`, `Tomcat`, `CIO`.

### JVM Version, Operating System, and Relevant Context
```
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
```
```
ProductName: Mac OS X
ProductVersion: 10.14.4
BuildVersion: 18E226
```

### Feedback
There's (maybe) a bug:

#### Steps to reproduce
The simple code below is enough to reproduce.

```
webSocket("/ws") {
close()
// or terminate()
// or close(CloseReason(...))
// or close(Exception())
}
```

Connection is not closing with Netty or Jetty engine, but closing with CIO or Tomcat.

Contributor guide

Open the contributing guide

Research direction

Start with the server webSocket("/ws") handler shown in the reproduction and trace how close(), terminate(), and close(CloseReason(...)) are handled by the Netty and Jetty engines. Compare their behavior with CIO and Tomcat, where closing works. Done means the reproduced server connection closes consistently on Netty and Jetty as well.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
backend, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.