ninenines / gun

HTTP/1.1, HTTP/2, Websocket client (and more) for Erlang/OTP.
ISC License
891 stars 232 forks source link

Unexpected event in state :domain_lookup of type :info: #275

Open riccardomanfrin opened 2 years ago

riccardomanfrin commented 2 years ago

Ciao,

I'm opening a listening socket with netcat nc -l 127.0.0.2 8081. Than I'm opening a gun connection like so:

gunopts = %{
      connect_timeout: 100,
      retry_timeout: 500,
      protocols: [:http2],
      http2_opts: %{
        keepalive: 15000,
        max_decode_table_size: 0,
        max_encode_table_size: 0
      }
    }
   {:ok, gunpid} = :gun.open(addr, port, gunopts)
   {:ok, protocol} = :gun.await_up(gunpid)

and I see the PRI * HTTP/2.0 section in netcat. Roughly half a second later I get this message:

15:37:28.233 [error] [pid=<0.868.0> ] - Unexpected event in state :domain_lookup of type :info:
{:timeout, #Reference<0.3804564456.1687945217.62829>, {:cow_http2_machine, :undefined, :settings_timeout}}
{:state, #PID<0.857.0>, {:up, #Reference<0.3804564456.1687945217.62825>},
 {127, 0, 0, 2}, 8081, "http", {127, 0, 0, 2}, 8081, [],
 %{
   connect_timeout: 100,
   http2_opts: %{
     keepalive: 15000,
     max_decode_table_size: 0,
     max_encode_table_size: 0
   },
   protocols: [:http2],
   retry_timeout: 500
 }, :undefined, :undefined, :gun_tcp, true, {:tcp, :tcp_closed, :tcp_error},
 :undefined, :undefined, :undefined, :gun_default_event_h, :undefined}

I'm new to http2, gun and most things in this world, and I know that a netcat socket doing nothing is not exactly an HTTP/2 server, but I don't quite understand this error (the domain_lookup state thing in particular), and even more, how to catch it (since the connection is gone after it).

Thanks in advance for your help

essen commented 2 years ago

I'm not sure why you're in the domain_lookup state, but that error is otherwise expected: the server doesn't acknowledge the initial SETTINGS frame and as a result the connection is dropped. You are not going to be able to get a connection using simply netcat.

That said the error should probably be fixed, thanks for reporting!

riccardomanfrin commented 2 years ago

yw, thanks for the fast reply too