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

EofStream and websocket.receive_* functions #6800

Open
socketpair opened this issue Jun 22, 2022 · 3 comments · May be fixed by #9511
Open

EofStream and websocket.receive_* functions #6800

socketpair opened this issue Jun 22, 2022 · 3 comments · May be fixed by #9511
Labels
bug good first issue Good for newcomers Hacktoberfest We think it's good for https://hacktoberfest.digitalocean.com/

Comments

@socketpair
Copy link
Contributor

socketpair commented Jun 22, 2022

aiohttp 3.8.1

await websocket.receive_json() Will die with TypeError on WSMsgType.CLOSED.

#2784 is fixed, yes:

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

Yes, bug is fixed in iterator but NOT fixed for websocket.receive_* functions, like receive_json()

I would raise RuntimeError or so if corresponding message "type" (like bytes, str, or json) can not be received.

@socketpair socketpair added the bug label Jun 22, 2022
@socketpair socketpair changed the title EofStream and autoclose EofStream and websocket.receive_* functions Jun 22, 2022
@rigtorp
Copy link

rigtorp commented Nov 23, 2022

First I want to thank the developers for this amazing library!

I have the same issue. The webscocket.receeive_* functions should throw ConnectionResetError when there are connection related errors instead of TypeError. It will already throw this error if the auto ping feature is enabled and the pong call fails.

@Dreamsorcerer Dreamsorcerer added good first issue Good for newcomers Hacktoberfest We think it's good for https://hacktoberfest.digitalocean.com/ labels Aug 30, 2024
@ara-25
Copy link

ara-25 commented Oct 5, 2024

Hi,
If this issue still persists and is available, then I would like to take it up for the hacktoberfest event.

@Dreamsorcerer
Copy link
Member

Yep, go ahead. I think you'll find those functions in aiotttp/client_ws.py.

@ara-25 ara-25 linked a pull request Oct 20, 2024 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue Good for newcomers Hacktoberfest We think it's good for https://hacktoberfest.digitalocean.com/
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants