apache / rocketmq-clients

RocketMQ Clients - Collection of Client Bindings for Apache RocketMQ
https://rocketmq.apache.org/
Apache License 2.0
327 stars 213 forks source link

[Bug] 中文环境每次调用产生错误,Error starting gRPC call,Request headers must contain only ASCII characters. #865

Open my1639963 opened 2 hours ago

my1639963 commented 2 hours ago

Before Creating the Bug Report

Programming Language of the Client

C#

Runtime Platform Environment

OS: Windows11 23H2.22631.4317 Microsoft Visual Studio Community 2022 (64 位) - Current 版本 17.10.3 .net 6

RocketMQ Version of the Client/Server

Server Version 5.3.1 Client 5.1.0

Run or Compiler Version

No response

Describe the Bug

代码片段如下:

            //通过configuration 读取appsettingappsetting.json配置
            var endpoint = confiuration["rocketmq:endpoint"];
            topic = confiuration["rocketmq:topic"];

            var clientConfig = new ClientConfig.Builder()
                .SetEndpoints(endpoint)
                .EnableSsl(false)
                .Build();

                _producer = new Producer.Builder()
                .SetTopics(topic) // 默认主题
                .SetClientConfig(clientConfig)
                .Build()
                .Result;
调用  new Producer.Builder() 时报错 
      An unhandled exception has occurred while executing the request.
      System.AggregateException: One or more errors occurred. (Status(StatusCode="Internal", Detail="Error starting gRPC call. HttpRequestException: Request headers must contain only ASCII characters.", DebugException="System.Net.Http.HttpRequestException: Request headers must contain only ASCII characters.
         at System.Net.Http.HPack.HPackEncoder.EncodeValueStringPart(String value, Span`1 destination)
         at System.Net.Http.HPack.HPackEncoder.EncodeStringLiteral(String value, Encoding valueEncoding, Span`1 destination, Int32& bytesWritten)
         at System.Net.Http.HPack.HPackEncoder.EncodeStringLiterals(ReadOnlySpan`1 values, String separator, Encoding valueEncoding, Span`1 destination, Int32& bytesWritten)
         at System.Net.Http.HPack.HPackEncoder.EncodeLiteralHeaderFieldWithoutIndexingNewName(String name, ReadOnlySpan`1 values, String separator, Encoding valueEncoding, Span`1 destination, Int32& bytesWritten)
         at System.Net.Http.Http2Connection.WriteLiteralHeader(String name, ReadOnlySpan`1 values, Encoding valueEncoding, ArrayBuffer& headerBuffer)
         at System.Net.Http.Http2Connection.WriteHeaderCollection(HttpRequestMessage request, HttpHeaders headers, ArrayBuffer& headerBuffer)
         at System.Net.Http.Http2Connection.WriteHeaders(HttpRequestMessage request, ArrayBuffer& headerBuffer)
         at System.Net.Http.Http2Connection.SendHeadersAsync(HttpRequestMessage request, CancellationToken cancellationToken, Boolean mustFlush)
         at System.Net.Http.Http2Connection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
         at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
         at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
         at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
         at System.Net.Http.HttpMessageInvoker.<SendAsync>g__SendAsyncWithTelemetry|6_0(HttpMessageHandler handler, HttpRequestMessage request, CancellationToken cancellationToken)
         at Grpc.Net.Client.Internal.GrpcCall`2.RunCall(HttpRequestMessage request, Nullable`1 timeout)"))
       ---> Grpc.Core.RpcException: Status(StatusCode="Internal", Detail="Error starting gRPC call. HttpRequestException: Request headers must contain only ASCII characters.", DebugException="System.Net.Http.HttpRequestException: Request headers must contain only ASCII characters.
         at System.Net.Http.HPack.HPackEncoder.EncodeValueStringPart(String value, Span`1 destination)
         at System.Net.Http.HPack.HPackEncoder.EncodeStringLiteral(String value, Encoding valueEncoding, Span`1 destination, Int32& bytesWritten)
         at System.Net.Http.HPack.HPackEncoder.EncodeStringLiterals(ReadOnlySpan`1 values, String separator, Encoding valueEncoding, Span`1 destination, Int32& bytesWritten)
         at System.Net.Http.HPack.HPackEncoder.EncodeLiteralHeaderFieldWithoutIndexingNewName(String name, ReadOnlySpan`1 values, String separator, Encoding valueEncoding, Span`1 destination, Int32& bytesWritten)
         at System.Net.Http.Http2Connection.WriteLiteralHeader(String name, ReadOnlySpan`1 values, Encoding valueEncoding, ArrayBuffer& headerBuffer)
         at System.Net.Http.Http2Connection.WriteHeaderCollection(HttpRequestMessage request, HttpHeaders headers, ArrayBuffer& headerBuffer)
         at System.Net.Http.Http2Connection.WriteHeaders(HttpRequestMessage request, ArrayBuffer& headerBuffer)
         at System.Net.Http.Http2Connection.SendHeadersAsync(HttpRequestMessage request, CancellationToken cancellationToken, Boolean mustFlush)
         at System.Net.Http.Http2Connection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
         at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
         at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
         at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
         at System.Net.Http.HttpMessageInvoker.<SendAsync>g__SendAsyncWithTelemetry|6_0(HttpMessageHandler handler, HttpRequestMessage request, CancellationToken cancellationToken)
         at Grpc.Net.Client.Internal.GrpcCall`2.RunCall(HttpRequestMessage request, Nullable`1 timeout)")
         at Grpc.Net.Client.Internal.GrpcCall`2.GetResponseHeadersCoreAsync()
         at Org.Apache.Rocketmq.ClientLoggerInterceptor.HandleResponse[TResponse](Task`1 t)
         at Org.Apache.Rocketmq.RpcClient.QueryRoute(Metadata metadata, QueryRouteRequest request, TimeSpan timeout)
         at Org.Apache.Rocketmq.ClientManager.QueryRoute(Endpoints endpoints, QueryRouteRequest request, TimeSpan timeout)
         at Org.Apache.Rocketmq.Client.FetchTopicRoute0(String topic)
         at Org.Apache.Rocketmq.Client.FetchTopicRoute(String topic)
         at Org.Apache.Rocketmq.Client.Start()
         at Org.Apache.Rocketmq.Producer.Start()
         at Org.Apache.Rocketmq.Producer.Builder.Build()
         --- End of inner exception stack trace ---

Steps to Reproduce

中文环境windows,每次调用必然触发

What Did You Expect to See?

...

What Did You See Instead?

...

Additional Context

No response

my1639963 commented 2 hours ago

Runtime Data image