You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When passing options for gun via the :adapter_opts key in the 3rd argument to the function GRPC.Stub.connect/3, if you specify the tcp_opts field (which should be of type [gen_tcp:connect_option()], see: https://ninenines.eu/docs/en/gun/2.0/manual/gun/) the field is always replaced with the value of @default_transport_opts.
To Reproduce
Ensure you are using gun v2 (you should be unless you specify a different version with override: true in your mix.exs) and make sure the gun application is loaded. Add some logging to GRPC.Stub.connect_insecurely/2 or trace :gun.open/3 using e.g. recon_trace:calls, and then call GRPC.Stub.connect(my_addr, my_port, [adapter_opts: %{tcp_opts: my_tcp_opts}]) where my_tcp_opts is a proplist containing some options you want to give to gun's tcp_opts field.
Expected behavior
The options passed to gun:open/3 should include the values you provided for the tcp_opts field. Instead you will find that you can only ever get the default tcp_opts value provided by the module attribute @default_transport_opts in the GRPC.Adapter.Gun module
Logs
Interactive Elixir (1.10.1)-pressCtrl+Ctoexit(typeh() ENTER for help)iex(1)>:code.ensure_loaded(:gun){:module,:gun}iex(2)>:recon_trace.calls({:gun,:open,:_},1)2iex(3)>grpc_opts=[adapter_opts: %{tcp_opts: [port: 6969,nodelay: true]}][adapter_opts: %{tcp_opts: [port: 6969,nodelay: true]}]iex(4)>GRPC.Stub.connect("localhost",50051,grpc_opts)14:26:13.021314<0.250.0>gun:open("localhost",50051,#{http2_opts=>#{settings_timeout=>infinity}, protocols=>[http2], retry=>100, retry_fun=>fun 'Elixir.GRPC.Adapter.Gun':retry_fun/2, tcp_opts=>[{nodelay,true}], transport=>tcp})Recontracerratelimittripped.
Additional context
The problem is that on lines 27 and 45 of GRPC.Adapter.Gun, the call to Map.merge/2 always replaces the value of tcp_opts in the first argument (which is the value supplied by the user) with the value in the second argument (the default value).
Note that things work as expected if the user is using gun v1 and instead uses the key transport_opts. Do we really need the checks to the version of gun here? I think it makes sense to just pass through whichever options the user supplies, since gun itself will validate the options when gun:open is called anyway.
The text was updated successfully, but these errors were encountered:
The related PR above seems to resolve the issue. The options still need to be passed through :transport_opts regardless if they you're using TCP or TLS, but other than that it seems to be working :)
Describe the bug
When passing options for gun via the
:adapter_opts
key in the 3rd argument to the functionGRPC.Stub.connect/3
, if you specify thetcp_opts
field (which should be of type[gen_tcp:connect_option()]
, see: https://ninenines.eu/docs/en/gun/2.0/manual/gun/) the field is always replaced with the value of@default_transport_opts
.To Reproduce
Ensure you are using gun v2 (you should be unless you specify a different version with
override: true
in yourmix.exs
) and make sure thegun
application is loaded. Add some logging toGRPC.Stub.connect_insecurely/2
or trace:gun.open/3
using e.g.recon_trace:calls
, and then callGRPC.Stub.connect(my_addr, my_port, [adapter_opts: %{tcp_opts: my_tcp_opts}])
wheremy_tcp_opts
is a proplist containing some options you want to give to gun'stcp_opts
field.Expected behavior
The options passed to
gun:open/3
should include the values you provided for thetcp_opts
field. Instead you will find that you can only ever get the default tcp_opts value provided by the module attribute@default_transport_opts
in theGRPC.Adapter.Gun
moduleLogs
Versions:
Additional context
The problem is that on lines 27 and 45 of
GRPC.Adapter.Gun
, the call toMap.merge/2
always replaces the value oftcp_opts
in the first argument (which is the value supplied by the user) with the value in the second argument (the default value).Note that things work as expected if the user is using gun v1 and instead uses the key
transport_opts
. Do we really need the checks to the version of gun here? I think it makes sense to just pass through whichever options the user supplies, since gun itself will validate the options whengun:open
is called anyway.The text was updated successfully, but these errors were encountered: