本文介绍了在GRPC服务器上将其吐出时,遇到流中尾帧意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将数据发送到grpc服务并得到错误消息作为回报:

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

遇到流尾中帧

这是什么意思.连接中断或其他数据发送不足.是我的客户端无法发送足够的消息数据,还是在处理过程中某些连接中断.我没有足够的信息.

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.

我正在使用Envoy代理(Lyft)中的此过滤器:

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

我正在使用Envoy的这座桥:

I am using this bridge from Envoy:

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

它要求开头为零字节,长度为大印第安语的为4个字节.

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);
   }




推荐答案

该错误消息表示服务器接收到部分数据,并且由于流的末尾为真,因此它不希望有更多数据来.

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.

这篇关于在GRPC服务器上将其吐出时,遇到流中尾帧意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 15:14