No `gun_down` or `gun_error` when connecting to non-existent host using `gun`

I’m probably missing something obvious here, but if I use gun:open to connect to a host that does not exist, or a port that has nothing listening on it, I don’t receive any error-message back.

For example, attempting to connect to port 81 on www.google.com (nothing is listening on port 81):

(xyz@machine)4> gun:open("www.google.com", 81, #{ protocols => [ http ], domain_lookup_timeout => 1000, connect_timeout => 1000, retry => 0 }).
{ok,<0.1218.0>}
(xyz@machine)5> flush().
ok

I would expect the flush to return a gun_down or gun_error tuple, but nothing. Same when connecting to non-existent hostname www.google1.com:

(xyz@machine)6> gun:open("www.google1.com", 81, #{ protocols => [ http ], domain_lookup_timeout => 1000, connect_timeout => 1000, retry => 0 }).
{ok,<0.1221.0>}
(xyz@machine)7> flush().
ok

I do receive a gun_up when connecting to something that does exist:

(xyz@machine)2> gun:open("www.google.com", 80, #{ protocols => [ http ], domain_lookup_timeout => 1000, connect_timeout => 1000, retry => 0 }).
{ok,<0.1215.0>}
(xyz@machine)3> flush().
Shell got {gun_up,<0.1215.0>,http}
ok

What am I overlooking? Am I misconfiguring something, or am I supposed to detect such errors in a different way?

This is using gun-2.0.0-rc2.

Thanks,

1 Like

I guess creating a monitor for the gun process would work… still feels odd that gun does not post events in case of such errors.

1 Like