reactphp / socket

Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP.
https://reactphp.org/socket/
MIT License
1.21k stars 157 forks source link

Make happy eyeballs algorithm (IPv6) the default, add new `happy_eyeballs` option to `Connector` #224

Closed clue closed 4 years ago

clue commented 4 years ago

The Connector class now defaults to using the happy eyeballs algorithm to automatically connect over IPv4 or IPv6 when a hostname is given. This automatically attempts to connect using both IPv4 and IPv6 at the same time (preferring IPv6), thus avoiding the usual problems faced by users with imperfect IPv6 connections or setups. If you want to revert to the old behavior of only doing an IPv4 lookup and only attempt a single IPv4 connection, you can set up the Connector like this:

$connector = new React\Socket\Connector($loop, array(
    'happy_eyeballs' => false
));

Supersedes / closes #216, thanks @WyriHaximus for the original version. On top of this, I've resolved a garbage reference in legacy PHP by avoiding some unneeded promise wrapping and simplifying this logic slightly.

clue commented 4 years ago

@CharlotteDunois @WyriHaximus I agree with what you're saying. These changes had been cherry-picked from #216 without modification, I've just updated this to skip the affected tests instead and improved some of the test timeouts to avoid some sporadic false negatives :+1:

clue commented 4 years ago

Updated slightly to fix a minor documentation typo :shipit: