New submission from Neil Booth <kyuupic...@gmail.com>:

I run a machine with IPv4 and IPv6 interfaces on MacOSX Mojave.

I try to loop.create_connection() to a remote machine whose domain resolves to 
an IPv6 address only, with a local_addr domain name argument that resolves to 
two local addresses: an IPv4 one first and an IPv6 one second.

The loop 
https://github.com/python/cpython/blob/master/Lib/asyncio/base_events.py#L927-L943
 that loops through the local addresses, IPv4 then IPv6, successfully binds the 
IPv4 laddr_info to the IPv6 socket successfully (something I find surprising) 
and then the connection attempt fails with OSError(65, 'No route to host'), at 
which point the sockets is closed and the IPv6 laddr_info is never tried and 
the connection attempt fails.

If I reverse the order of the loop so that the IPv6 laddr_info is tried first 
then the connection succeeds.

I suggest either all laddr_info bindings should be tried for each outer loop of 
infos, rather than just 1, or that those of a different socket "type" (IPv4 vs 
IPv6) should be skipped in the inner loop before attempting a binding.

----------
components: asyncio
messages: 330354
nosy: asvetlov, kyuupichan, yselivanov
priority: normal
severity: normal
status: open
title: create_connection with local_addr misses valid socket bindings
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35302>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to