Skip to content

Commit

Permalink
Document how to override DNS resolution.
Browse files Browse the repository at this point in the history
Ref #1343.
  • Loading branch information
aaugustin committed May 18, 2023
1 parent 9c578a1 commit 73394df
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 10 additions & 0 deletions docs/faq/client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ In the :mod:`threading` API, this argument is named ``additional_headers``::
with connect(..., additional_headers={"Authorization": ...}) as websocket:
...

How do I force the IP address that the client connects to?
----------------------------------------------------------

Use the ``host`` argument of :meth:`~asyncio.loop.create_connection`::

await websockets.connect("ws://example.com", host="192.168.0.1")

:func:`~client.connect` accepts the same arguments as
:meth:`~asyncio.loop.create_connection`.

How do I close a connection?
----------------------------

Expand Down
8 changes: 5 additions & 3 deletions docs/faq/server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,12 @@ It's available in :attr:`~legacy.protocol.WebSocketCommonProtocol.remote_address
async def handler(websocket):
remote_ip = websocket.remote_address[0]

How do I set the IP addresses my server listens on?
---------------------------------------------------
How do I set the IP addresses that my server listens on?
--------------------------------------------------------

Look at the ``host`` argument of :meth:`~asyncio.loop.create_server`.
Use the ``host`` argument of :meth:`~asyncio.loop.create_server`::

await websockets.serve(handler, host="192.168.0.1", port=8080)

:func:`~server.serve` accepts the same arguments as
:meth:`~asyncio.loop.create_server`.
Expand Down

0 comments on commit 73394df

Please sign in to comment.