Connecting to node.js gRPC server running on Google Cloud Run always return frame_size_error
Describe the question Hi everyone, I'm struggling with using ellixir-grpc/grpc to connect with gRPC server running on Google Cloud Run. I'm trying to run code like below.
parsed_html = "test"
endpoint = System.get_env("HTML_PARSER_ENDPOINT")
{:ok, channel} = GRPC.Stub.connect(endpoint)
request = ParseRequest.new(html: parsed_html)
{:ok, reply} = channel |> Parser.Stub.parse(request)
However, it always return
{:error, %GRPC.RPCError{message: ":connection_error: :frame_size_error", status: 13}}
So, my current workaround is to use grpcurl.
endpoint = System.get_env("HTML_PARSER_ENDPOINT")
data = Jason.encode!(%{html: parsed_html})
{reply_json, _} = System.cmd("grpcurl", ["-proto", "parser.proto", "-d", data, endpoint, "Parser.Parse"])
mapped = reply_json |> String.replace("\n", "") |> String.trim |> Jason.decode!
parsed = mapped["parsed"] |> String.replace("\n", "") |> String.trim
custom_css = mapped["css"] |> String.replace("\n", "") |> String.trim
With this workaround, I can make it work, but I'd like to use elixir-grpc if it is possible so that I don't need to install go and grpcurl to the container.
Also, I receive error after few seconds I connected to the channel
{:ok, channel} = GRPC.Stub.connect(endpoint)
[error] Unexpected event in state :domain_lookup of type :info:
{:timeout, #Reference<0.4083940386.1712586757.185928>, {:cow_http2_machine, :preface_timeout}}
{:state, #PID<0.680.0>, {:up, #Reference<0.4083940386.1712586756.184423>},
'myendpoint', 443, "http",
'myendpoint', 443, [],
%{
http2_opts: %{settings_timeout: :infinity},
protocols: [:http2],
retry: 100,
retry_fun: &GRPC.Adapter.Gun.retry_fun/2,
tcp_opts: [nodelay: true],
transport: :tcp
}, :undefined, :undefined, :gun_tcp, true, {:tcp, :tcp_closed, :tcp_error},
:undefined, :undefined, :gun_default_event_h, :undefined}
Versions:
- OS: Mac 11.6
- Erlang: Erlang/OTP 24
- Elixir: Elixir 1.13.1
- mix.lock(grpc, gun, cowboy, cowlib): cowboy: 2.9.0 {:grpc, github: "elixir-grpc/grpc"}, {:cowlib, "~> 2.9.0", override: true}, {:gun, "~> 2.0.0", hex: :grpc_gun, override: true}
@hiro1107 do you have a repo which reproduces this bug easily?
We have been trying to achieve a similar thing with a nodejs server and trying to connect with the elixir app but getting the same error. The current workaround is to use grpcurl, however, it would be great if this can be resolved and we are able to use the elixir client itself.