eclipse-vertx / eclipse-vertx/vertx-grpc

The gRPC server bidirectional streams do not receive exceptions when the client loses connectivity

Open
#28 1 comment 1 reaction 1 assignee Claimed by @vietj View on GitHub
bug
Dominant language
Java
Stars
53
Forks
36
Avg merge
5h 49m
Merged PRs (30d)
60

Description

### Version

4.3.7

### Context

Using `request.exceptionHandler(...)`, bidirectional streams can respond to ungraceful stream closure, which could be killing an app, a browser crashing, a phone running out of battery, network disconnection or other failure.

This package does not correctly receive exceptions the way Netty does. It lacks the configuration that the Netty server has for keep alives. This appears to be the root issue.

### Steps to reproduce

1. Generate a bidi streaming method stub using the original Netty-based Vertx package's `jprotoc` based code generator. You will have a method of the signature:
```java
void bidiCall(ReadStream request, WriteStream response);
```
2. Bind it to the Netty-based `VertxServer`. Configure it with timeouts:
```java
var builder = VertxServerBuilder.forPort(vertx, port);
var nettyServerBuilder = builder.nettyBuilder();
nettyServerBuilder
.maxConnectionIdle(Long.MAX_VALUE, TimeUnit.NANOSECONDS)
.maxConnectionAge(29, TimeUnit.DAYS)
.keepAliveTime(400, TimeUnit.MILLISECONDS)
.keepAliveTimeout(8000, TimeUnit.MILLISECONDS)
.permitKeepAliveTime(100, TimeUnit.MILLISECONDS)
.permitKeepAliveWithoutCalls(true);
builder.build();
```
3. Proxy the server with ToxiProxy.
4. Connect to the bidi RPC endpoint.
5. Observe you are connected.
6. Disconnect the network using ToxiProxy.
7. After a short while, observe a `StatusRuntimeException` with status `Status.CANCELLED` is delivered to `request.exceptionHandler`.
8. Bind the same service to a `GrpcServer`.
9. Proxy it with ToxiProxy.
10. Connect to the bidi RPC endpoint.
11. Observe you are connected.
12. Disconnect the network using ToxiProxy.
13. Observe no exception is received nor the `endHandler` called in a short while.

### Extra

This is reproduced in the tests of my own open source program. I can share that one. Otherwise I will need help authoring tests in this package, since Maven in my IntelliJ does not appear to generate the protos / reference them correctly and it's impossible to code. Additionally I suggest adding TestContainers as a dependency for using ToxiProxy.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.