What does Encountered end-of-stream mid-frame mean

2019-08-19 23:26发布

I am sending data to grpc service and getting error message in return:

Encountered end-of-stream mid-frame

What does this mean. the connection was interrupted or something else like not enough data sent across. Was it a failure of my client to send enough data of the message over or was it some connection break in the middle of processing. I dont have enough information from this.

If you dont know whats wrong here just tell me if it means the connection closed too early during processing or the datafeed was just not as long as expected but there was no connection problem.

I am using this filter from Envoy proxy (Lyft):

I am using this bridge from Envoy:

https://www.envoyproxy.io/docs/envoy/latest/configuration/http_filters/grpc_http1_bridge_filter

It asks for zero byte up front and 4 bytes with big indian of the length.

For me its a long ugly and meaningless message:

Jul 23, 2019 2:26:06 PM io.grpc.netty.shaded.io.grpc.netty.NettyServerStream$TransportState deframeFailed
WARNING: Exception processing message
io.grpc.StatusRuntimeException: INTERNAL: Encountered end-of-stream mid-frame
    at io.grpc.Status.asRuntimeException(Status.java:524)
    at io.grpc.internal.AbstractServerStream$TransportState.deframerClosed(AbstractServerStream.java:238)
    at io.grpc.netty.shaded.io.grpc.netty.NettyServerStream$TransportState.deframerClosed(NettyServerStream.java:155)
    at io.grpc.internal.MessageDeframer.close(MessageDeframer.java:229)
    at io.grpc.internal.MessageDeframer.deliver(MessageDeframer.java:296)
    at io.grpc.internal.MessageDeframer.request(MessageDeframer.java:161)
    at io.grpc.internal.AbstractStream$TransportState.requestMessagesFromDeframer(AbstractStream.java:205)
    at io.grpc.netty.shaded.io.grpc.netty.NettyServerStream$Sink$1.run(NettyServerStream.java:100)
    at io.grpc.netty.shaded.io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
    at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
    at io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:333)
    at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:905)
    at io.grpc.netty.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:748)

14:26:06.445 [grpc-default-worker-ELG-3-2] DEBUG io.grpc.netty.shaded.io.grpc.netty.NettyServerHandler - [id: 0xd01ed34c, L:/127.0.0.1:9009 - R:/127.0.0.1:48042] OUTBOUND RST_STREAM: streamId=45 errorCode=8```


Is there something wrong with the client?

//Define a postRequest request
    HttpPost postRequest = new        HttpPost("http://10.10.xx.xx:31380/com.test.EchoService/echo");

//Set the API media type in http content-type header
    postRequest.addHeader("content-type", "application/grpc");


    int messageLength=EchoRequest.newBuilder()
        .setMessage("Hello"+ ": " + Thread.currentThread().getName())
        .build().getMessageBytes().toByteArray().length;

    byte[] lengthBytes =   ByteBuffer.allocate(4).putInt(messageLength).array();

    byte[] zeroByte = {0};

    byte[] messageBytes = EchoRequest.newBuilder()
        .setMessage("Hello" + ": " + Thread.currentThread().getName())
        .build().getMessageBytes().toByteArray();



    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    baos.write(zeroByte);
    baos.write(lengthBytes);
    baos.write(messageBytes);
    byte[] c = baos.toByteArray();

//Set the request post body
    StringEntity userEntity = new StringEntity(content);
    ByteArrayEntity bae = new ByteArrayEntity(baos.toByteArray());
    postRequest.setEntity(userEntity);

    //Send the request; It will immediately return the response in      HttpResponse object if any
    HttpResponse response = httpClient.execute(postRequest);

    //verify the valid error code first
    int statusCode = response.getStatusLine().getStatusCode();
    if (statusCode != 201)
   {
        throw new RuntimeException("Failed with HTTP error code : " +    statusCode);
   }




1条回答
聊天终结者
2楼-- · 2019-08-19 23:59

the error message means, the server received partial data, and it doesn't expect more data coming since the end of stream is true.

based on the error message, the length is probably larger than actual proto payload.

查看更多
登录 后发表回答