Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocketResponse.close code/message don't reach the client #3448

Closed
JoseKilo opened this issue Dec 12, 2018 · 12 comments · Fixed by #8680
Closed

WebSocketResponse.close code/message don't reach the client #3448

JoseKilo opened this issue Dec 12, 2018 · 12 comments · Fixed by #8680
Assignees
Labels

Comments

@JoseKilo
Copy link

JoseKilo commented Dec 12, 2018

Long story short

Following this example from the docs
https://docs.aiohttp.org/en/stable/web_advanced.html?highlight=going_away#graceful-shutdown

The code and message passed to ws.close don't reach the client side and instead, a default code and message is used.

Expected behaviour

I would expect that the code and message should reach the client.
If I'm wrong, the documentation could explain why this is not the case.

Actual behaviour

Default code and message are returned (code=1000, message=b'')

Steps to reproduce

The commented-out asserts fail.

import weakref

import aiohttp.http
import aiohttp.web


async def websocket_handler(request):
    websocket = aiohttp.web.WebSocketResponse()
    await websocket.prepare(request)
    request.app["websockets"].add(websocket)

    try:
        async for message in websocket:
            await websocket.send_json({"ok": True, "message": message.json()})
    finally:
        request.app["websockets"].discard(websocket)

    return websocket


async def on_shutdown(app):
    for websocket in set(app["websockets"]):
        await websocket.close(
            code=aiohttp.WSCloseCode.GOING_AWAY,
            message="Server shutdown",
        )


async def test_foo(aiohttp_client):
    url = "/ws"
    app = aiohttp.web.Application()
    app["websockets"] = weakref.WeakSet()
    app.router.add_get(url, websocket_handler)
    app.on_shutdown.append(on_shutdown)

    client = await aiohttp_client(app)

    websocket = await client.ws_connect(url)

    message = {"message": "hi"}
    await websocket.send_json(message)
    reply = await websocket.receive_json()
    assert reply == {"ok": True, "message": message}

    await app.shutdown()

    assert websocket.closed is False

    reply = await websocket.receive()

    assert reply.type == aiohttp.http.WSMsgType.CLOSE
    assert reply.data == aiohttp.WSCloseCode.OK
    assert reply.extra == ""
    # assert reply.data == aiohttp.WSCloseCode.GOING_AWAY
    # assert reply.extra == "Server shutdown"
    assert websocket.closed is True

Your environment

Python 3.6.7

aiohttp==3.4.4
pytest==4.0.1
pytest-aiohttp==0.3.0
@aio-libs-bot
Copy link

GitMate.io thinks the contributor most likely able to help you is @asvetlov.

Possibly related issues are #3391 (WebSocketResponse requires closing/closed checks before sending something), #2309 (WebSocketResponse does not throw/close when connection is abruptly cut), #1043 (Automatically close unclosed responses returned by test client), #2595 (Server handler halts after client connection closed), and #694 (Async iterator never returns close message).

@vir-mir
Copy link
Member

vir-mir commented Jan 6, 2019

@JoseKilo Hi!

This tangled history, in the documentation bug.

You need to have a separate WeakSet for the on_shutdown task, or you can not remove it from app['websockets'] if you use it only for shutdown

I added app['shutdown_websockets'] and now my test works correctly.

import weakref

import aiohttp.http
import aiohttp.web


async def websocket_handler(request):
    websocket = aiohttp.web.WebSocketResponse()
    await websocket.prepare(request)
    request.app["websockets"].add(websocket)

    request.app["shutdown_websockets"].add(websocket)

    try:
        async for message in websocket:
            await websocket.send_json({"ok": True, "message": message.json()})
    finally:
        request.app["websockets"].discard(websocket)

    return websocket


async def on_shutdown(app):
    while app['shutdown_websockets']:
        websocket = app['shutdown_websockets'].pop()
        await websocket.close(
            code=aiohttp.WSCloseCode.GOING_AWAY,
            message="Server shutdown",
        )


async def test_foo(aiohttp_client):
    url = "/ws"
    app = aiohttp.web.Application()
    app["websockets"] = weakref.WeakSet()

    # need for send signal shutdown server
    app["shutdown_websockets"] = weakref.WeakSet()

    app.router.add_get(url, websocket_handler)
    app.on_shutdown.append(on_shutdown)

    client = await aiohttp_client(app)

    websocket = await client.ws_connect(url)

    message = {"message": "hi"}
    await websocket.send_json(message)
    reply = await websocket.receive_json()
    assert reply == {"ok": True, "message": message}

    await app.shutdown()

    assert websocket.closed is False

    reply = await websocket.receive()

    assert reply.type == aiohttp.http.WSMsgType.CLOSE
    assert reply.data == aiohttp.WSCloseCode.GOING_AWAY
    assert reply.extra == "Server shutdown"

    assert websocket.closed is True

@vir-mir
Copy link
Member

vir-mir commented Jan 7, 2019

@JoseKilo thought of your question.

@asvetlov @jettify @webknjaz it really turns out that you have to intervene in the logic of the iteration, to organize the proper cleaning of dead sockets and use on_shutdown.

You can use this approach.
I created async iterator RespIter to change the logic of the iteration of WebSocketResponse

This allows you to clear the app [" websockets "] before exiting the iteration loop. which will allow the use of app [" websockets "] by leaving the server in shutdown.

class RespIter(AsyncIterator):
    __slots__ = ('_response', '_websockets')

    def __init__(self, response, websockets):
        self._response = response
        self._websockets = websockets

    async def __anext__(self):
        try:
            return await self._response.__anext__()
        except StopAsyncIteration:
            self._websockets.discard(self._response)
            raise StopAsyncIteration

You also need to change the iteration loop and clear the app ['websockets'] only in case of an error.

async def websocket_handler(request):
    websocket = aiohttp.web.WebSocketResponse()
    await websocket.prepare(request)

    request.app["websockets"].add(websocket)

    try:
        async for message in RespIter(websocket, request.app["websockets"]):
            await websocket.send_json({"ok": True, "message": message.json()})
    except Exception as e:
        request.app["websockets"].discard(websocket)
        raise e

Full code and tests:

import weakref
from collections.abc import AsyncIterator

import aiohttp.http
import aiohttp.web


class RespIter(AsyncIterator):
    __slots__ = ('_response', '_websockets')

    def __init__(self, response, websockets):
        self._response = response
        self._websockets = websockets

    async def __anext__(self):
        try:
            return await self._response.__anext__()
        except StopAsyncIteration:
            self._websockets.discard(self._response)
            raise StopAsyncIteration


async def websocket_handler(request):
    websocket = aiohttp.web.WebSocketResponse()
    await websocket.prepare(request)

    request.app["websockets"].add(websocket)

    try:
        async for message in RespIter(websocket, request.app["websockets"]):
            await websocket.send_json({"ok": True, "message": message.json()})
    except Exception as e:
        request.app["websockets"].discard(websocket)
        raise e


async def on_shutdown(app):
    while app['websockets']:
        websocket = app['websockets'].pop()
        await websocket.close(
            code=aiohttp.WSCloseCode.GOING_AWAY,
            message="Server shutdown",
        )


async def test_foo(aiohttp_client):
    url = "/ws"
    app = aiohttp.web.Application()
    app["websockets"] = weakref.WeakSet()

    app.router.add_get(url, websocket_handler)
    app.on_shutdown.append(on_shutdown)

    client = await aiohttp_client(app)

    websocket = await client.ws_connect(url)
    assert len(app["websockets"]) == 1
    await websocket.close()
    assert len(app["websockets"]) == 0

    websocket = await client.ws_connect(url)
    assert len(app["websockets"]) == 1
    await websocket.send_str('asdc')
    reply = await websocket.receive()
    assert reply.type == aiohttp.http.WSMsgType.CLOSED
    assert len(app["websockets"]) == 0

    websocket = await client.ws_connect(url)
    assert len(app["websockets"]) == 1
    message = {"message": "hi"}
    await websocket.send_json(message)
    reply = await websocket.receive_json()
    assert reply == {"ok": True, "message": message}

    await app.shutdown()

    assert websocket.closed is False

    reply = await websocket.receive()

    assert len(app["websockets"]) == 0

    assert reply.type == aiohttp.http.WSMsgType.CLOSE
    assert reply.data == aiohttp.WSCloseCode.GOING_AWAY
    assert reply.extra == "Server shutdown"

    assert websocket.closed is True

@Roman1us
Copy link

Bump issue.

@vir-mir In you example, if websocket_handler return websocket var, test will fail. In docs handler always return WebSocketResponse. So, in my tests when i use wscat and handler without return (return None) i got

Unhandled runtime exception
Traceback (most recent call last):
  File "aiohttp/web_protocol.py", line 580, in finish_response
    prepare_meth = resp.prepare
AttributeError: 'NoneType' object has no attribute 'prepare'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "aiohttp/web_protocol.py", line 485, in start
    resp, reset = await task
  File "aiohttp/web_protocol.py", line 440, in _handle_request
    reset = await self.finish_response(request, resp, start_time)
  File "aiohttp/web_protocol.py", line 583, in finish_response
    raise RuntimeError("Missing return " "statement on request handler")
RuntimeError: Missing return statement on request handler

Any ideas?

@PARTHAVPATEL28
Copy link

Bump issue.

@vir-mir In you example, if websocket_handler return websocket var, test will fail. In docs handler always return WebSocketResponse. So, in my tests when i use wscat and handler without return (return None) i got

Unhandled runtime exception
Traceback (most recent call last):
  File "aiohttp/web_protocol.py", line 580, in finish_response
    prepare_meth = resp.prepare
AttributeError: 'NoneType' object has no attribute 'prepare'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "aiohttp/web_protocol.py", line 485, in start
    resp, reset = await task
  File "aiohttp/web_protocol.py", line 440, in _handle_request
    reset = await self.finish_response(request, resp, start_time)
  File "aiohttp/web_protocol.py", line 583, in finish_response
    raise RuntimeError("Missing return " "statement on request handler")
RuntimeError: Missing return statement on request handler

Any ideas?

@Roman1us were you able to find solution for the above error? I am facing the same issue in my code.

@wodny
Copy link

wodny commented Dec 30, 2021

This problem goes beyond custom code not reaching the client during application shutdown. I observe the same problem (aiohttp 3.8.1) when calling WebSocketResponse.close() during normal application operation, eg. when I want to break a WS connection if the client is no longer allowed to receive notifications.

The root cause seems to be WebSocketResponse.close() closing the reader (reader.feed_data(WS_CLOSING_MESSAGE, 0)) before actually sending the code itself. This causes the reader loop (async for message in websocket) to finish and the handler to exit. This causes the second call to WebSocketResponse.close() which finishes before the first call resumes. So the readers's closure "steals" the opportunity to send the final code and sends the default one.

The workaround I found isn't pretty because there is no public API to await the first close() until it finishes. Inside the handler, after the reader loop and before returning the response I added:

    while not websocket.closed:
        await asyncio.sleep(.1)

This ensures that the second call to close() by the reader after the WebSocketResponse is returned from the handler will omit the "stealing" part due to the if not self._closed condition. The first close() will win the race even if it resumes later than the second call.

@AirbornePorcine
Copy link

Thanks @wodny - we've been scratching our heads on this exact issue, and the workaround you mentioned is functional, if not pretty as you said.

@eLvErDe
Copy link

eLvErDe commented Nov 8, 2023

@wodny Thanks a lot for figuring this out, you're a savior

@Dreamsorcerer
Copy link
Member

Dreamsorcerer commented Aug 11, 2024

@bdraco Maybe one you'd be interested in? If you take the reproducer in the original post, this is based on our documentation examples, but doesn't work correctly.

There seems to be a race condition. First we call .close() in the shutdown handler, which internally will end up awaiting ._close_wait.
Then when we return from the handler, that also calls .close() (with a different status code), but ._waiting is now False because we've exited the receive loop and it immediately continues with the close logic.
Then the first .close() call gets to resume, but it's already closed and sent the message by then, so it returns immediately without ever sending that first close message.

@bdraco
Copy link
Member

bdraco commented Aug 11, 2024

I’ll add it to my queue

@bdraco bdraco self-assigned this Aug 11, 2024
@Dreamsorcerer
Copy link
Member

Dreamsorcerer commented Aug 11, 2024

I'm not sure if it's necessarily the correct solution to this, but if we yield to the event loop before exiting the async for loop, then it works correctly:

    async def __anext__(self) -> WSMessage:
        msg = await self.receive()
        if msg.type in (WSMsgType.CLOSE, WSMsgType.CLOSING, WSMsgType.CLOSED):
            await asyncio.sleep(0)  # <---
            raise StopAsyncIteration
        return msg

@bdraco
Copy link
Member

bdraco commented Aug 11, 2024

Reordering breaking the receive with the feed_data to after sending the close message, but before the reader.read() calls to fix the race.

I made that change in #8680 and adapted the above test. It passes now

github-actions bot pushed a commit that referenced this issue Sep 13, 2024
Bumps [urllib3](https:/urllib3/urllib3) from 2.2.2 to 2.2.3.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https:/urllib3/urllib3/releases">urllib3's
releases</a>.</em></p>
<blockquote>
<h2>2.2.3</h2>
<h2>🚀 urllib3 is fundraising for HTTP/2 support</h2>
<p><a
href="https://sethmlarson.dev/urllib3-is-fundraising-for-http2-support">urllib3
is raising ~$40,000 USD</a> to release HTTP/2 support and ensure
long-term sustainable maintenance of the project after a sharp decline
in financial support for 2023. If your company or organization uses
Python and would benefit from HTTP/2 support in Requests, pip, cloud
SDKs, and thousands of other projects <a
href="https://opencollective.com/urllib3">please consider contributing
financially</a> to ensure HTTP/2 support is developed sustainably and
maintained for the long-haul.</p>
<p>Thank you for your support.</p>
<h2>Features</h2>
<ul>
<li>Added support for Python 3.13. (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3473">#3473</a>)</li>
</ul>
<h2>Bugfixes</h2>
<ul>
<li>Fixed the default encoding of chunked request bodies to be UTF-8
instead of ISO-8859-1. All other methods of supplying a request body
already use UTF-8 starting in urllib3 v2.0. (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3053">#3053</a>)</li>
<li>Fixed ResourceWarning on CONNECT with Python &lt; 3.11.4 by
backporting <a
href="https://redirect.github.com/python/cpython/issues/103472">python/cpython#103472</a>.
(`<a
href="https://redirect.github.com/urllib3/urllib3/issues/3252">#3252</a>)</li>
<li>Adjust tolerance for floating-point comparison on Windows to avoid
flakiness in CI (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3413">#3413</a>)</li>
<li>Fixed a crash where certain standard library hash functions were
absent in restricted environments. (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3432">#3432</a>)</li>
<li>Fixed mypy error when adding to
<code>HTTPConnection.default_socket_options</code>. (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3448">#3448</a>)</li>
</ul>
<h2>HTTP/2 (experimental)</h2>
<p>HTTP/2 support is still in early development.</p>
<ul>
<li>Excluded Transfer-Encoding: chunked from HTTP/2 request body (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3425">#3425</a>)</li>
<li>Added version checking for <code>h2</code> (<a
href="https://pypi.org/project/h2/">https://pypi.org/project/h2/</a>)
usage. Now only accepting supported h2 major version 4.x.x. (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3290">#3290</a>)</li>
<li>Added a probing mechanism for determining whether a given target
origin supports HTTP/2 via ALPN. (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3301">#3301</a>)</li>
<li>Add support for sending a request body with HTTP/2 (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3302">#3302</a>)</li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https:/urllib3/urllib3/compare/2.2.2...2.2.3">https:/urllib3/urllib3/compare/2.2.2...2.2.3</a></p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https:/urllib3/urllib3/blob/main/CHANGES.rst">urllib3's
changelog</a>.</em></p>
<blockquote>
<h1>2.2.3 (2024-09-12)</h1>
<h2>Features</h2>
<ul>
<li>Added support for Python 3.13.
(<code>[#3473](urllib3/urllib3#3473)
&lt;https:/urllib3/urllib3/issues/3473&gt;</code>__)</li>
</ul>
<h2>Bugfixes</h2>
<ul>
<li>Fixed the default encoding of chunked request bodies to be UTF-8
instead of ISO-8859-1.
All other methods of supplying a request body already use UTF-8 starting
in urllib3 v2.0.
(<code>[#3053](urllib3/urllib3#3053)
&lt;https:/urllib3/urllib3/issues/3053&gt;</code>__)</li>
<li>Fixed ResourceWarning on CONNECT with Python <!-- raw HTML omitted
-->`__)</li>
<li>Adjust tolerance for floating-point comparison on Windows to avoid
flakiness in CI
(<code>[#3413](urllib3/urllib3#3413)
&lt;https:/urllib3/urllib3/issues/3413&gt;</code>__)</li>
<li>Fixed a crash where certain standard library hash functions were
absent in restricted environments.
(<code>[#3432](urllib3/urllib3#3432)
&lt;https:/urllib3/urllib3/issues/3432&gt;</code>__)</li>
<li>Fixed mypy error when adding to
<code>HTTPConnection.default_socket_options</code>.
(<code>[#3448](urllib3/urllib3#3448)
&lt;https:/urllib3/urllib3/issues/3448&gt;</code>__)</li>
</ul>
<h2>HTTP/2 (experimental)</h2>
<p>HTTP/2 support is still in early development.</p>
<ul>
<li>
<p>Excluded Transfer-Encoding: chunked from HTTP/2 request body
(<code>[#3425](urllib3/urllib3#3425)
&lt;https:/urllib3/urllib3/issues/3425&gt;</code>__)</p>
</li>
<li>
<p>Added version checking for <code>h2</code> (<a
href="https://pypi.org/project/h2/">https://pypi.org/project/h2/</a>)
usage.</p>
<p>Now only accepting supported h2 major version 4.x.x.
(<code>[#3290](urllib3/urllib3#3290)
&lt;https:/urllib3/urllib3/issues/3290&gt;</code>__)</p>
</li>
<li>
<p>Added a probing mechanism for determining whether a given target
origin
supports HTTP/2 via ALPN.
(<code>[#3301](urllib3/urllib3#3301)
&lt;https:/urllib3/urllib3/issues/3301&gt;</code>__)</p>
</li>
<li>
<p>Add support for sending a request body with HTTP/2
(<code>[#3302](urllib3/urllib3#3302)
&lt;https:/urllib3/urllib3/issues/3302&gt;</code>__)</p>
</li>
</ul>
<h2>Deprecations and Removals</h2>
<ul>
<li>Note for downstream distributors: the <code>_version.py</code> file
has been removed and is now created at build time by hatch-vcs.
(<code>[#3412](urllib3/urllib3#3412)
&lt;https:/urllib3/urllib3/issues/3412&gt;</code>__)</li>
<li>Drop support for end-of-life PyPy3.8 and PyPy3.9.
(<code>[#3475](urllib3/urllib3#3475)
&lt;https:/urllib3/urllib3/issues/3475&gt;</code>__)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https:/urllib3/urllib3/commit/2458bfcd3dacdf6c196e98d077fc6bb02a5fc1df"><code>2458bfc</code></a>
Release 2.2.3</li>
<li><a
href="https:/urllib3/urllib3/commit/9b25db6d00e43858d49303ae55c43bc4a9832668"><code>9b25db6</code></a>
Only attempt to publish for upstream</li>
<li><a
href="https:/urllib3/urllib3/commit/b9adeef8501180cd7d04cc3fb90bed4bbc34b1bb"><code>b9adeef</code></a>
Drop support for EOL PyPy3.8 and PyPy3.9</li>
<li><a
href="https:/urllib3/urllib3/commit/b1d4649d43375f11a3072b4d9b5d33425d123bae"><code>b1d4649</code></a>
Add explicit support for Python 3.13</li>
<li><a
href="https:/urllib3/urllib3/commit/cc42860721836febf3fb6ebb485ed27d7f80122d"><code>cc42860</code></a>
Bump cryptography from 42.0.4 to 43.0.1 (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3470">#3470</a>)</li>
<li><a
href="https:/urllib3/urllib3/commit/3dae2e9b30d2e39bf20daea2353aa7ef055640cf"><code>3dae2e9</code></a>
Bump pypa/gh-action-pypi-publish from 1.9.0 to 1.10.1 (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3469">#3469</a>)</li>
<li><a
href="https:/urllib3/urllib3/commit/1e94feb2a671bf28721114dfea1105a2c1f91788"><code>1e94feb</code></a>
Revert &quot;Add TLS settings for HTTP/2 (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3456">#3456</a>)&quot;
(<a
href="https://redirect.github.com/urllib3/urllib3/issues/3466">#3466</a>)</li>
<li><a
href="https:/urllib3/urllib3/commit/aa73abc7b22a4a67e0ee957f5a3031109f73d3d9"><code>aa73abc</code></a>
Bump actions/setup-python from 5.1.0 to 5.2.0 (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3468">#3468</a>)</li>
<li><a
href="https:/urllib3/urllib3/commit/abbfbcb1dd274fc54b4f0a7785fd04d59b634195"><code>abbfbcb</code></a>
Add 1.26.20 to changelog and make the publish workflow the same (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3464">#3464</a>)</li>
<li><a
href="https:/urllib3/urllib3/commit/d48061505e72271116c5a33b04dbca6273f2a737"><code>d480615</code></a>
Add TLS settings for HTTP/2 (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3456">#3456</a>)</li>
<li>Additional commits viewable in <a
href="https:/urllib3/urllib3/compare/2.2.2...2.2.3">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=urllib3&package-manager=pip&previous-version=2.2.2&new-version=2.2.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
github-actions bot pushed a commit that referenced this issue Sep 16, 2024
Bumps [urllib3](https:/urllib3/urllib3) from 2.2.2 to 2.2.3.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https:/urllib3/urllib3/releases">urllib3's
releases</a>.</em></p>
<blockquote>
<h2>2.2.3</h2>
<h2>🚀 urllib3 is fundraising for HTTP/2 support</h2>
<p><a
href="https://sethmlarson.dev/urllib3-is-fundraising-for-http2-support">urllib3
is raising ~$40,000 USD</a> to release HTTP/2 support and ensure
long-term sustainable maintenance of the project after a sharp decline
in financial support for 2023. If your company or organization uses
Python and would benefit from HTTP/2 support in Requests, pip, cloud
SDKs, and thousands of other projects <a
href="https://opencollective.com/urllib3">please consider contributing
financially</a> to ensure HTTP/2 support is developed sustainably and
maintained for the long-haul.</p>
<p>Thank you for your support.</p>
<h2>Features</h2>
<ul>
<li>Added support for Python 3.13. (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3473">#3473</a>)</li>
</ul>
<h2>Bugfixes</h2>
<ul>
<li>Fixed the default encoding of chunked request bodies to be UTF-8
instead of ISO-8859-1. All other methods of supplying a request body
already use UTF-8 starting in urllib3 v2.0. (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3053">#3053</a>)</li>
<li>Fixed ResourceWarning on CONNECT with Python &lt; 3.11.4 by
backporting <a
href="https://redirect.github.com/python/cpython/issues/103472">python/cpython#103472</a>.
(`<a
href="https://redirect.github.com/urllib3/urllib3/issues/3252">#3252</a>)</li>
<li>Adjust tolerance for floating-point comparison on Windows to avoid
flakiness in CI (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3413">#3413</a>)</li>
<li>Fixed a crash where certain standard library hash functions were
absent in restricted environments. (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3432">#3432</a>)</li>
<li>Fixed mypy error when adding to
<code>HTTPConnection.default_socket_options</code>. (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3448">#3448</a>)</li>
</ul>
<h2>HTTP/2 (experimental)</h2>
<p>HTTP/2 support is still in early development.</p>
<ul>
<li>Excluded Transfer-Encoding: chunked from HTTP/2 request body (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3425">#3425</a>)</li>
<li>Added version checking for <code>h2</code> (<a
href="https://pypi.org/project/h2/">https://pypi.org/project/h2/</a>)
usage. Now only accepting supported h2 major version 4.x.x. (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3290">#3290</a>)</li>
<li>Added a probing mechanism for determining whether a given target
origin supports HTTP/2 via ALPN. (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3301">#3301</a>)</li>
<li>Add support for sending a request body with HTTP/2 (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3302">#3302</a>)</li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https:/urllib3/urllib3/compare/2.2.2...2.2.3">https:/urllib3/urllib3/compare/2.2.2...2.2.3</a></p>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https:/urllib3/urllib3/blob/main/CHANGES.rst">urllib3's
changelog</a>.</em></p>
<blockquote>
<h1>2.2.3 (2024-09-12)</h1>
<h2>Features</h2>
<ul>
<li>Added support for Python 3.13.
(<code>[#3473](urllib3/urllib3#3473)
&lt;https:/urllib3/urllib3/issues/3473&gt;</code>__)</li>
</ul>
<h2>Bugfixes</h2>
<ul>
<li>Fixed the default encoding of chunked request bodies to be UTF-8
instead of ISO-8859-1.
All other methods of supplying a request body already use UTF-8 starting
in urllib3 v2.0.
(<code>[#3053](urllib3/urllib3#3053)
&lt;https:/urllib3/urllib3/issues/3053&gt;</code>__)</li>
<li>Fixed ResourceWarning on CONNECT with Python <!-- raw HTML omitted
-->`__)</li>
<li>Adjust tolerance for floating-point comparison on Windows to avoid
flakiness in CI
(<code>[#3413](urllib3/urllib3#3413)
&lt;https:/urllib3/urllib3/issues/3413&gt;</code>__)</li>
<li>Fixed a crash where certain standard library hash functions were
absent in restricted environments.
(<code>[#3432](urllib3/urllib3#3432)
&lt;https:/urllib3/urllib3/issues/3432&gt;</code>__)</li>
<li>Fixed mypy error when adding to
<code>HTTPConnection.default_socket_options</code>.
(<code>[#3448](urllib3/urllib3#3448)
&lt;https:/urllib3/urllib3/issues/3448&gt;</code>__)</li>
</ul>
<h2>HTTP/2 (experimental)</h2>
<p>HTTP/2 support is still in early development.</p>
<ul>
<li>
<p>Excluded Transfer-Encoding: chunked from HTTP/2 request body
(<code>[#3425](urllib3/urllib3#3425)
&lt;https:/urllib3/urllib3/issues/3425&gt;</code>__)</p>
</li>
<li>
<p>Added version checking for <code>h2</code> (<a
href="https://pypi.org/project/h2/">https://pypi.org/project/h2/</a>)
usage.</p>
<p>Now only accepting supported h2 major version 4.x.x.
(<code>[#3290](urllib3/urllib3#3290)
&lt;https:/urllib3/urllib3/issues/3290&gt;</code>__)</p>
</li>
<li>
<p>Added a probing mechanism for determining whether a given target
origin
supports HTTP/2 via ALPN.
(<code>[#3301](urllib3/urllib3#3301)
&lt;https:/urllib3/urllib3/issues/3301&gt;</code>__)</p>
</li>
<li>
<p>Add support for sending a request body with HTTP/2
(<code>[#3302](urllib3/urllib3#3302)
&lt;https:/urllib3/urllib3/issues/3302&gt;</code>__)</p>
</li>
</ul>
<h2>Deprecations and Removals</h2>
<ul>
<li>Note for downstream distributors: the <code>_version.py</code> file
has been removed and is now created at build time by hatch-vcs.
(<code>[#3412](urllib3/urllib3#3412)
&lt;https:/urllib3/urllib3/issues/3412&gt;</code>__)</li>
<li>Drop support for end-of-life PyPy3.8 and PyPy3.9.
(<code>[#3475](urllib3/urllib3#3475)
&lt;https:/urllib3/urllib3/issues/3475&gt;</code>__)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https:/urllib3/urllib3/commit/2458bfcd3dacdf6c196e98d077fc6bb02a5fc1df"><code>2458bfc</code></a>
Release 2.2.3</li>
<li><a
href="https:/urllib3/urllib3/commit/9b25db6d00e43858d49303ae55c43bc4a9832668"><code>9b25db6</code></a>
Only attempt to publish for upstream</li>
<li><a
href="https:/urllib3/urllib3/commit/b9adeef8501180cd7d04cc3fb90bed4bbc34b1bb"><code>b9adeef</code></a>
Drop support for EOL PyPy3.8 and PyPy3.9</li>
<li><a
href="https:/urllib3/urllib3/commit/b1d4649d43375f11a3072b4d9b5d33425d123bae"><code>b1d4649</code></a>
Add explicit support for Python 3.13</li>
<li><a
href="https:/urllib3/urllib3/commit/cc42860721836febf3fb6ebb485ed27d7f80122d"><code>cc42860</code></a>
Bump cryptography from 42.0.4 to 43.0.1 (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3470">#3470</a>)</li>
<li><a
href="https:/urllib3/urllib3/commit/3dae2e9b30d2e39bf20daea2353aa7ef055640cf"><code>3dae2e9</code></a>
Bump pypa/gh-action-pypi-publish from 1.9.0 to 1.10.1 (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3469">#3469</a>)</li>
<li><a
href="https:/urllib3/urllib3/commit/1e94feb2a671bf28721114dfea1105a2c1f91788"><code>1e94feb</code></a>
Revert &quot;Add TLS settings for HTTP/2 (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3456">#3456</a>)&quot;
(<a
href="https://redirect.github.com/urllib3/urllib3/issues/3466">#3466</a>)</li>
<li><a
href="https:/urllib3/urllib3/commit/aa73abc7b22a4a67e0ee957f5a3031109f73d3d9"><code>aa73abc</code></a>
Bump actions/setup-python from 5.1.0 to 5.2.0 (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3468">#3468</a>)</li>
<li><a
href="https:/urllib3/urllib3/commit/abbfbcb1dd274fc54b4f0a7785fd04d59b634195"><code>abbfbcb</code></a>
Add 1.26.20 to changelog and make the publish workflow the same (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3464">#3464</a>)</li>
<li><a
href="https:/urllib3/urllib3/commit/d48061505e72271116c5a33b04dbca6273f2a737"><code>d480615</code></a>
Add TLS settings for HTTP/2 (<a
href="https://redirect.github.com/urllib3/urllib3/issues/3456">#3456</a>)</li>
<li>Additional commits viewable in <a
href="https:/urllib3/urllib3/compare/2.2.2...2.2.3">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=urllib3&package-manager=pip&previous-version=2.2.2&new-version=2.2.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants