Skip to content

websockets close unexpected behavior #3550

Closed as not planned
Closed as not planned

Description

@lmarent

Long story short

unexpected processing during shutdown

Expected behaviour

I am writing a server code that connects clients though WebSockets. The server that I coded calls the close all Websockets connected (maintained in a set as the documentation recommends), and I expect the code calls the close() method of the websocket as many time as web sockets are connected.

Actual behaviour

Right now, there is only one close being called. After the first call, it is like the server continues executing the rest of the shutdown processing.

Steps to reproduce

Start the server with python server.py
Start two clients with with python client.py

Ctrl-C on the sever and you only see one print with the label closing websocket

Your environment

OS: UBUNTU 16.04
Python: 3.6

Libraries Installed
aiohttp==3.5.1
async-timeout==3.0.1
attrs==18.2.0
chardet==3.0.4
idna==2.8
idna-ssl==1.1.0
multidict==4.5.2
typing-extensions==3.6.6
yarl==1.3.0

files.zip

Activity

  1. aio-libs-bot commented on Jan 17, 2019

    @aio-libs-bot

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

    Possibly related issues are #194 (websockets), #301 (Secure Websockets?), #691 (Websockets are automatically closed after response), #754 (How to close websockets coroutines ?), and #753 (Websockets in variables).

  2. lmarent commented on Jan 22, 2019

    @lmarent
    Author

    Hello I saw all the possible related issues and none one applies. The closest is issue 754 and it talks about how to close the client websocket connection. My case applies for web sockets closed by server request.

  3. dzhalaevd commented on Apr 30, 2023

    @dzhalaevd
    Contributor

    Hello, @lmarent, there has been no activity here for the last 3 years, can you confirm that this is still a problem? Also I've reviewed your code and suggest that you consider using asyncio.wait_for() or asyncio.sleep(0) in the on_shutdown() function for better handling of program shutdown. These functions may help ensure that all connections are properly closed before the program terminates.

  4. added
    needs-infoIssue is lacking sufficient information and will be closed if not provided
    on Aug 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Staleneeds-infoIssue is lacking sufficient information and will be closed if not provided

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions