{"id":8071,"date":"2020-04-03T21:39:59","date_gmt":"2020-04-03T21:39:59","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=8071"},"modified":"2020-04-03T21:39:59","modified_gmt":"2020-04-03T21:39:59","slug":"the-unavailable-trying-to-connect-an-http1-x-server-grpc-error","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/the-unavailable-trying-to-connect-an-http1-x-server-grpc-error\/","title":{"rendered":"The &#8220;UNAVAILABLE: Trying to connect an http1.x server&#8221; gRPC error"},"content":{"rendered":"<p>I&#8217;m working with on C# client library using gRpc. This is not a web based library where there&#8217;s a need for <em>envoy<\/em> or other application to help work with HTTP2. Instead this was on a C# client using tcp\/ip.<\/p>\n<p>Everything was working fine on my machine until the machine was relocated (not that this specifically was the problem as I later found out others were having similar problems, some times intermittently) at which point I found that the client would exception with the message &#8220;UNAVAILABLE: Trying to connect an http1.x server&#8221;.<\/p>\n<p><em>Note: if you turn on all exceptions within Visual Studio, you&#8217;ll firstly see an exception where grpc tries to get a <em>Value<\/em> from a Nullable when it&#8217;s null (this was the call to Native.grpcsharp_batch_context_recv_message_length). This is a red herring, it&#8217;s simple that the nullable is null which seems to be expected behaviour, maybe should be handled in the gRPC .NET library code.<\/em><\/p>\n<p>Testing the client on another machine demonstrated the problem was seemingly network related, turns out it was HTTP proxy related to be precise. <\/p>\n<p>This doesn&#8217;t seem to be too well documented from what I could tell, but setting the ChannelOption grpc.enable_http_proxy to 0 (see https:\/\/grpc.github.io\/grpc\/core\/group__grpc__arg__keys.html) fixed the problem.<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nvar channel = new ManagedChannel(\r\n   host, \r\n   port, \r\n   ChannelCredentials.Insecure,\r\n   new &#x5B;]{ new ChannelOption(&quot;grpc.enable_http_proxy&quot;, 0)} );\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m working with on C# client library using gRpc. This is not a web based library where there&#8217;s a need for envoy or other application to help work with HTTP2. Instead this was on a C# client using tcp\/ip. Everything was working fine on my machine until the machine was relocated (not that this specifically [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3,221],"tags":[],"class_list":["post-8071","post","type-post","status-publish","format-standard","hentry","category-c","category-grpc"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8071","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=8071"}],"version-history":[{"count":5,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8071\/revisions"}],"predecessor-version":[{"id":8087,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8071\/revisions\/8087"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=8071"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=8071"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=8071"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}