python-websockets / websockets

Library for building WebSocket servers and clients in Python
https://websockets.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
5.19k stars 514 forks source link

How do I specific another network interface while using websockets.asyncio.client.connect ? #1529

Closed yo123abxd closed 4 days ago

yo123abxd commented 4 days ago

Hello, I want to init several connections using distinct network interface, for example: eth0, eth1, eth2, etc. I have browsed the document and issues, but I cannot find any informations.

Please help. Thank you.

aaugustin commented 4 days ago

Set a local_addr parameter when calling connect. It will be passed through to create_connection.

yo123abxd commented 3 days ago

Thank you for your help. How about websockets.sync.client.connect? I set local_addr when calling websockets.asyncio.client.connect. And it worked. But when I passed local_addr to websockets.sync.client.connect, it raised a TypeError: create_connection() got an unexpected keyword argument 'local_addr'.

aaugustin commented 3 days ago

Parameter is called source_address and it's passed through to socket.create_connection.