google-cloud-dotnet: HTTP version error when publishing message via proxy with PublisherClient

We publish messages to PubSub using the PublisherClient. When running from the production environment we set a proxy. However, when the code executes it throws the following error:

Only HTTP/1.0 and HTTP/1.1 version requests are currently supported. Parameter name: value

Full stack trace: Error: One or more errors occurred. Status(StatusCode=“Internal”, Detail=“Error starting gRPC call. ArgumentException: Only HTTP/1.0 and HTTP/1.1 version requests are currently supported. Parameter name: value”, DebugException=“System.ArgumentException: Only HTTP/1.0 and HTTP/1.1 version requests are currently supported. Parameter name: value at System.Net.HttpWebRequest.set_ProtocolVersion(Version value) at System.Net.Http.HttpClientHandler.CreateAndPrepareWebRequest(HttpRequestMessage request) at System.Net.Http.HttpClientHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at Grpc.Net.Client.Internal.GrpcCall`2.<RunCall>d__73.MoveNext() in /_/src/Grpc.Net.Client/Internal/GrpcCall.cs:line 493”)

How do I set for example http 1.1 when I create the PublisherClient? The line that throws the exception is:

return await publisherClient.PublishAsync(message);

The code currently looks like this (with starting point method PublishMessage:

public async Task<string> PublishMessage(string projectId, string topicId, string message)
{
    TopicName topicName = TopicName.FromProjectTopic(projectId, topicId);
    PublisherClient publisherClient = await GetPublisherClient(topicName);       
    
    return await publisherClient.PublishAsync(message);
 }
 private PublisherClient publisherClient1 = null;
 private async Task<PublisherClient> GetPublisherClient(TopicName topicName)
 {
    if (publisherClient1 == null)
    {
        publisherClient1 = _useProxy ? GetClientWithProxy(topicName) : await PublisherClient.CreateAsync(topicName);
    }

    return publisherClient1;
 }
private PublisherClient GetClientWithProxy(TopicName topicName)
{
    WebProxy proxy = new WebProxy(_nordnetProxyUrl, _nordnetWebProxyPort);
    PublisherClient publisher = new PublisherClientBuilder
    {
        TopicName = topicName,
        GrpcAdapter = GrpcNetClientAdapter.Default.WithAdditionalOptions(options => options.HttpHandler = new HttpClientHandler
        {
            Proxy = proxy,
            UseProxy = true
        })
    }.Build();

    return publisher;
}

Some technical information:

  • The code is developed using .NET Framework v4.8
  • Running on server with OS "Windows Server 2016 Datacenter (have also tried on Windows Server 2019 v1809 with same error message)

I’m using the following versions of Google-libraries in my code (listing all of them 'cause I don’t know exactly which ones are relevant):

  • Google.Cloud.PubSubV1 - 3.3.0
  • Google.Api.CommonProtos - 2.7.0
  • Google.Api.Gax - 4.3.0
  • Google.Api.Gax.Grcp - 4.3.0
  • Google.Apis - 1.58.0
  • Google.Apis.Auth - 1.58.0
  • Google.Apis.Core - 1.58.0
  • Google.Cloud.Iam.V1 - 3.0.0
  • Grcp.Auth - 2.51.0
  • Grcp.Core - 2.46.5
  • Grcp.Core.Api - 2.51.0
  • Grcp.Net.Client - 2.51.0
  • Grcp.Net.Common - 2.51.0

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 35

Most upvoted comments

Glad everything is resolved though. I’ll close this issue now; I should be able to update the troubleshooting docs later in the week.