Open hu-chia opened 3 months ago
I believe this problem is the same as #28 , and #28 provides a workaround.
If you use vert.x grpc server, the keep-alive
workaround is unavailable, depending on #74
can someone provide a reproducer for this ?
@vietj here you are.
// filename: echo.proto
syntax = "proto3";
service EchoGrpc {
rpc Bidirectional(stream Str) returns (stream Str) {}
}
message Str {
string val = 1;
}
follow this
import Echo.Str;
import EchoGrpcGrpc.EchoGrpcImplBase;
import io.grpc.stub.StreamObserver;
import io.vertx.core.Vertx;
import io.vertx.grpc.server.GrpcServer;
import io.vertx.grpc.server.GrpcServiceBridge;
public class Main {
public static void main(String... args) throws InterruptedException {
var vertx = Vertx.vertx();
var grpcServer = GrpcServer.server(vertx);
var bridge = GrpcServiceBridge.bridge(new EchoGrpcImpl());
bridge.bind(grpcServer);
var httpServer = vertx.createHttpServer();
httpServer.requestHandler(grpcServer);
httpServer.listen(8080);
Thread.currentThread().join();
}
static class EchoGrpcImpl extends EchoGrpcImplBase {
@Override
public StreamObserver<Str> bidirectional(StreamObserver<Str> responseObserver) {
return new StreamObserver<Str>() {
@Override public void onNext(Str value) {
System.out.println("on next " + value);
responseObserver.onNext(value);
}
@Override public void onError(Throwable t) {
System.out.println("on error");
t.printStackTrace(System.out);
responseObserver.onError(t);
}
@Override public void onCompleted() {
System.out.println("on completed");
responseObserver.onCompleted();
}
};
}
}
}
brew install grpcurl
Ctrl + C
you might see:
$ while true; do echo '{"val":"hello,world"}'; sleep 1; done | grpcurl -proto echo.proto -plaintext -d @ localhost:8080 EchoGrpc/Bidirectional
{
"val": "hello,world"
}
{
"val": "hello,world"
}
{
"val": "hello,world"
}
^C
and serverside:
on next val: "hello,world"
on next val: "hello,world"
on next val: "hello,world"
No completion or error message
Questions
When I using
GrpcServiceBridgeImpl
, some of the behavior of vertx-grpc is not as expected when the network is abnormal.Expect Behavior
https://github.com/eclipse-vertx/vertx-grpc/blob/fca746c4f3f6bc4cf4e372fe8dd08ad3c9a2dc4a/vertx-grpc-server/src/main/java/io/vertx/grpc/server/impl/GrpcServiceBridgeImpl.java#L148-L157
if the network between client and server was interrupted,
listener.onCancel()
should be invoked.Actual Behavior
nothing happened.
Version
4.5.7
The
errorHandler
is an method fromGrpcReadStream
, it was invoked only when the httpStream has aStreamResetException
, but when client was killed, anIOException
occurred.https://github.com/eclipse-vertx/vertx-grpc/blob/fca746c4f3f6bc4cf4e372fe8dd08ad3c9a2dc4a/vertx-grpc-common/src/main/java/io/vertx/grpc/common/impl/GrpcReadStreamBase.java#L71-L81