@@ -117,11 +117,10 @@ init(#{hosts := Hosts,
117117
118118 ? DEBUG (" ~ts : trying to connect to replica at ~0p " , [Name , Hosts ]),
119119
120- case maybe_connect (Name , Transport , Hosts , Port , connect_options ())
121- of
120+ case maybe_connect (Name , Transport , Hosts , Port , connect_options ()) of
122121 {ok , Sock , Host } ->
123- ? DEBUG_ (Name , " successfully connected to host ~0p port ~b " ,
124- [Host , Port ]),
122+ ? INFO_ (Name , " replica reader successfully connected to host ~0p port ~b " ,
123+ [Host , Port ]),
125124 CntId = {? MODULE , ExtRef , Host , Port },
126125 CntSpec = {CntId , ? COUNTER_FIELDS },
127126 Config = #{counter_spec => CntSpec , transport => Transport },
@@ -177,7 +176,7 @@ init(#{hosts := Hosts,
177176 {error , Reason } ->
178177 ? WARN_ (Name , " could not connect replica reader to replica at ~0p port ~b , Reason: ~0p " ,
179178 [Hosts , Port , Reason ]),
180- {stop , Reason }
179+ {error , Reason }
181180 end .
182181
183182% %--------------------------------------------------------------------
@@ -391,34 +390,40 @@ setopts(tcp, Sock, Opts) ->
391390setopts (ssl , Sock , Opts ) ->
392391 ok = ssl :setopts (Sock , Opts ).
393392
394- maybe_connect (_Name , _ , [], _Port , _Options ) ->
393+
394+ maybe_connect (Name , T , Hosts , Port , Options ) ->
395+ maybe_connect (Name , T , Hosts , Port , Options , []).
396+
397+ maybe_connect (Name , _ , [], Port , _Options , Acc ) ->
398+ ? INFO_ (Name , " could not connect replica reader to replica on port ~b , "
399+ " reason(s): ~0p " , [Port , Acc ]),
395400 {error , connection_refused };
396- maybe_connect (Name , tcp , [H | T ], Port , Options ) ->
401+ maybe_connect (Name , tcp , [H | T ], Port , Options , Acc ) ->
397402 ? DEBUG_ (Name , " trying to connect to ~0p on port ~b " , [H , Port ]),
398403 case gen_tcp :connect (H , Port , Options ) of
399404 {ok , Sock } ->
400405 {ok , Sock , H };
401406 {error , Reason } ->
402407 ? DEBUG_ (Name , " connection refused, reason: ~w host:~0p - port: ~0p " ,
403408 [Reason , H , Port ]),
404- maybe_connect (Name , tcp , T , Port , Options )
409+ maybe_connect (Name , tcp , T , Port , Options , [{ H , Reason } | Acc ] )
405410 end ;
406- maybe_connect (Name , ssl , [H | T ], Port , Options ) ->
411+ maybe_connect (Name , ssl , [H | T ], Port , Options , Acc ) ->
407412 ? DEBUG_ (Name , " trying to establish TLS connection to ~0p using port ~b " , [H , Port ]),
408413 Opts = Options ++
409414 application :get_env (osiris , replication_client_ssl_options , []) ++
410415 maybe_add_sni_option (H ),
411416 case ssl :connect (H , Port , Opts ) of
412417 {ok , Sock } ->
413418 {ok , Sock , H };
414- {error , {tls_alert , {handshake_failure , _ }}} ->
419+ {error , {tls_alert , {handshake_failure = R , _ }}} ->
415420 ? DEBUG_ (Name , " TLS connection refused (handshake failure), host:~0p - port: ~0p " ,
416421 [H , Port ]),
417- maybe_connect (Name , ssl , T , Port , Options );
422+ maybe_connect (Name , ssl , T , Port , Options , [{ H , R } | Acc ] );
418423 {error , E } ->
419424 ? DEBUG_ (Name , " TLS connection refused, host:~0p - port: ~0p " , [H , Port ]),
420425 ? DEBUG_ (Name , " error while trying to establish TLS connection ~0p " , [E ]),
421- maybe_connect (Name , ssl , T , Port , Options )
426+ maybe_connect (Name , ssl , T , Port , Options , [{ H , E } | Acc ] )
422427 end .
423428
424429maybe_add_sni_option (H ) when is_binary (H ) ->
0 commit comments