Closed ospaarmann closed 6 years ago
Could you see the stacktrace? One strange thing is grpc-elixir doesn't use code
, which in your errors looks like status
of GPRC.RPCError
.
btw, what's the version of gun
in your mix.lock
?
Please try lock your gun at 1.0.0-pre.5
. I just realized that 1.0.0-pre.4b
is newer than 1.0.0-pre.5
on hex, which is weird.
I seem to have both versions in my mix.lock
"grpc": {:hex, :grpc, "0.3.0-alpha.1", "a43385d5b1974341fc4751b090b6528986f693d9637b8854de1dec14399e8cee", [:mix], [{:cowboy, "~> 2.2", [hex: :cowboy, repo: "hexpm", optional: false]}, {:gun, ">= 1.0.0-pre.5", [hex: :gun, repo: "hexpm", optional: false]}, {:protobuf, "~> 0.5", [hex: :protobuf, repo: "hexpm", optional: false]}], "hexpm"},
"gun": {:hex, :gun, "1.0.0-pre.4b", "dd53b9fd3d597cfa7974d6ad85128ac7e16a408d6dc8c392a532aa36eb032a5d", [:rebar3], [{:cowlib, "2.1.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.4.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm"}
Locking gun to 1.0.0-pre.5
got rid of the errors above. Now still some of my tests are failing with
%GRPC.RPCError{message: "shouldn't finish when getting headers", status: 13}
So it's an improvement 😄. Btw. my deps in mix.exs
looks like this now:
defp deps do
[
{:grpc, "~> 0.3.0-alpha.1"},
{:gun, "1.0.0-pre.5", override: true},
{:protobuf, "~> 0.5"},
{:poison, "~> 3.1"},
{:poolboy, "~> 1.5.1"},
{:db_connection, "~> 1.1"},
{:retry, "~> 0.8"},
{:uuid, "~> 1.1"},
{:morphix, "~> 0.2.1"},
{:ex_doc, "~> 0.16", only: :dev, runtime: false},
{:mix_test_watch, "~> 0.5", only: :dev, runtime: false},
{:excoveralls, "~> 0.8", only: :test}
]
end
I could push the current changes to a feature branch for my client if this helps you. I don't have any further stacktrace at this point.
Thanks!
I have published the feature branch with the described behaviour: https://github.com/ospaarmann/exdgraph/tree/use_grpc_hex_package
What's your function call when you got the error? Could you point out the code? I found it's a little complex to run dgraph 😂
If possible, could you captures packages and send the file to me? I wrote a wiki about this https://github.com/tony612/grpc-elixir/wiki/How-to-capture-HTTP-2-packages-using-Wireshark
I guess I known the reason, the server side returns error directly. You can add these two code
IO.inspect(status)
IO.inspect(headers)
before this line https://github.com/tony612/grpc-elixir/blame/master/lib/grpc/adapter/gun.ex#L130 in deps/grpc
. Then run mix deps.compile grpc
to see what's the status.
I'll improve the error message in the next release.
Hey,
I tried logging status
and headers
as you advised. But nothing showed up when running the tests. I also added another IO.puts/1
call to make sure they weren't just nil
. Still no output at all.
This is the changed code in /lib/grpc/adapter/gun.ex. And yes, I recompiled everything running mix clean
mix deps.compile grpc
and mix compile
.
defp await(conn_pid, stream_ref, timeout) do
case :gun.await(conn_pid, stream_ref, timeout) do
{:response, :fin, status, headers} ->
IO.puts("GUN ERROR")
IO.inspect(status)
IO.inspect(headers)
{:error,
GRPC.RPCError.exception(GRPC.Status.internal(), "shouldn't finish when getting headers")}
{:response, :nofin, status, headers} ->
if status == 200 do
{:response, headers}
else
{:error, GRPC.RPCError.exception(GRPC.Status.internal(), "status got is not 200")}
end
{:data, :fin, _} ->
{:error,
GRPC.RPCError.exception(GRPC.Status.internal(), "shouldn't finish when getting data")}
{:data, :nofin, data} ->
{:data, data}
trailers = {:trailers, _} ->
trailers
{:error, :timeout} ->
{:error, GRPC.RPCError.exception(GRPC.Status.deadline_exceeded(), "deadline exceeded")}
{:error, {reason, msg}} ->
{:error, GRPC.RPCError.exception(GRPC.Status.unknown(), "#{reason}: #{msg}")}
{:error, reason} ->
{:error, GRPC.RPCError.exception(GRPC.Status.unknown(), "#{inspect(reason)}")}
other ->
{:error,
GRPC.RPCError.exception(
GRPC.Status.unknown(),
"unexpected message when waiting: #{inspect(other)}"
)}
end
end
Strange thing though: When I changed the error message in the code itself it didn't change in the output.
On further inspection: My bad. I had to run MIX_ENV=test mix deps.compile grpc
to make the changes show up in my tests.
I receive the following errors ("GUN ERROR" comes from me...):
GUN ERROR
200
[
{"content-type", "application/grpc"},
{"grpc-status", "2"},
{"grpc-message", "while lexing INVALID: Invalid operation type: INVALID"}
]
GUN ERROR
200
[
{"content-type", "application/grpc"},
{"grpc-status", "2"},
{"grpc-message", "while lexing INVALID: Invalid operation type: INVALID"}
]
So the server actually returns what I am waiting for but it is not passed on or something.
Okay. I knew this issue already, it'll be fixed later.
Very nice! Do you have an aprox. timeline for the fix? Can I support you? Thanks!
@ospaarmann Could you try the master branch?
@tony612 I now receive new errors in my tests:
{:error,
%ArgumentError{
message: "the Access calls for keywords expect the key to be an atom, got: \"grpc-status\""
}}
@ospaarmann Try again? I need to add more tests 😅
Yes. That works now! 💯
@tony612 In which Hex release will this fix be included? Would be great to know so I can go forward publishing my package. Thanks.
@ospaarmann I plan to release a new version in this week after some issues I already know are fixed.
@ospaarmann 0.3.0-alpha.2 is released.
@tony612 Any timeline for a stable / non-alpha release? Still cannot publish my package with a pre-release dependency.
One problem is gun, which grpc depends on, is not stable. Do you use client, server side or both? On Thu, Apr 26, 2018 at 05:44 Ole Spaarmann notifications@github.com wrote:
@tony612 https://github.com/tony612 Any timeline for a stable / non-alpha release? Still cannot publish my package with a pre-release dependency.
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/tony612/grpc-elixir/issues/53#issuecomment-384444234, or mute the thread https://github.com/notifications/unsubscribe-auth/ABMhG8yWVOVPDouz72cXTDIdWucSYSjrks5tsO5FgaJpZM4S8FmI .
Client side. It is a database client for Dgraph. I now published it also as pre-release on hex.pm.
When upgrading from master on GitHub to 0.3.0-alpha.1 and running my client again I encounter a couple of new errors when trying to connect to a Server (Dgraph) using GRPC:
** (KeyError) key :code not found in: %CaseClauseError{term: {:error, %GRPC.RPCError{message: "{:stream_error, :protocol_error, :\"Malformed response; missing :status in HEADERS frame. (RFC7540 8.1.2.4)\"}", status: 2}}}
** (MatchError) no match of right hand side value: {:error, [code: 2, message: "{:connection_error, :compression_error, :\"Error while trying to decode HPACK-encoded header block. (RFC7540 4.3)\"}"]}
** (MatchError) no match of right hand side value: {:error, [code: 2, message: ":noproc"]}
** (MatchError) no match of right hand side value: {:error, [code: 13, message: "shouldn't finish when getting headers"]}
I tried upgrading protobuf-elixir and protoc-gen-elixir. No luck.
Before I start digging into my code: Any idea what is going on here?
Thank you!