Connection is being forcefully terminated
- Dominant language
- Rust
- Stars
- 12.5k
- Forks
- 1.3k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 24
Description
## Bug Report
server
```rust
let svc = ServiceBuilder::new()
.concurrency_limit(100_000)
.load_shed();
let mut server = Server::builder()
.tls_config(tls_config)
.unwrap()
.concurrency_limit_per_connection(256)
.tcp_keepalive(Some(Duration::from_secs(60)))
.http2_keepalive_interval(Some(Duration::from_secs(20)))
.http2_keepalive_timeout(Some(Duration::from_secs(60)))
.max_concurrent_streams(Some(512))
.layer(svc)
.layer(SessionMiddlewareLayer::new(db, redis_connection_manager));
....
let listener = TcpListener::bind(SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, CONFIG.port))).await.map_err(|e| {
eprintln!("Failed to bind TCP listener: {}", e);
e.to_string()
})?;
let incoming = TcpIncoming::from(listener)
.inspect_err(|e| {
if let Some(raw_os_error) = e.raw_os_error() {
if raw_os_error == libc::EMFILE {
println!("FD exhausted (EMFILE): {}", raw_os_error);
}
}
// if let Some(io) = e.downcast_ref::() {
// if io.raw_os_error() == Some(libc::EMFILE) {
// println!("FD exhausted (EMFILE): {io}");
// }
// }
});
server.serve_with_incoming(incoming)
.await.map_err(|e| {
eprintln!("gRPC Server Error: {}", e);
e.to_string()
})
```
client
```dart
final channel = ClientChannel(
actualHost,
port: actualPort,
options: ChannelOptions(
credentials: MyChannelCredentials.secure(selfSecurityContext()),
codecRegistry: CodecRegistry(codecs: [GzipCodec(), IdentityCodec()]),
keepAlive: ClientKeepAliveOptions(
pingInterval: Duration(seconds: 20),
permitWithoutCalls: true,
),
),
);
final options = CallOptions(providers: [_metadataProvider]);
final interceptors = [_ErrorHandlingInterceptor(() => onUnauthenticated)];
```
### Version
```
tonic v0.14.2
tonic-prost v0.14.2
tonic v0.14.2 (*)
tonic-prost-build v0.14.2
tonic-build v0.14.0
```
### Platform
Windows x64
### Description
`gRPC Error (code: 2, codeName: UNKNOWN, message: HTTP/2 error: Connection error: Connection is being forcefully terminated. (errorCode: 10), details: null, rawResponse: null, trailers: {})`
This error occurs when using persistent connections (server streams) or during server-side breakpoint debugging. When deployed to production, I sometimes get a large number of `FD exhausted (EMFILE)` messages, but the cause is unknown. Is there any way to prevent interruptions and avoid the `FD exhausted (EMFILE)` message?
Contributor guide
Assessment
This issue has not been assessed yet.