question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Websocket hangs with Windows and Python 3.8

See original GitHub issue

Connection via websockets hangs when running on Windows with Python 3.8, nest_asyncio, and the default WindowsProactorEventLoopPolicy. A simple program can reproduce this:

import asyncio
import nest_asyncio
from websockets import connect

nest_asyncio.apply()

async def _connect():
    websocket = await connect('wss://wss.foo.com:9876')

def client():
    loop = asyncio.get_event_loop()
    return loop.run_until_complete(_connect())

if __name__ == "__main__":
    client()

This works on other platforms/Python versions/policy, or without nest_asyncio. I did a little bit of tracing, and it looks like the connect() completed successfully, but it somehow got stuck when selecting the next event.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
erdewitcommented, Oct 25, 2020

This is released now in v1.4.2.

1reaction
WestXucommented, Aug 11, 2020

pip install nest_asyncio==1.3.3 fixes it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Websocket freezes program if no clients are connected
The problem is that when no client is connected, program freezes, missing events from translation which runs in real time. How can I...
Read more >
websocket-client - PyPI
websocket -client is a WebSocket client for Python. It provides access to low level APIs for WebSockets. websocket-client implements version hybi-13 of the ......
Read more >
Socket Timeout — An Important and Sometimes Complicated ...
During my experience working with Python, I've had several cases where a network client was left hanging while trying to request a server....
Read more >
Changelog — Python 3.11.1 documentation
gh-89237: Fix hang on Windows in subprocess.wait_closed() in asyncio with ... process user as was the default in Python 3.8 and earlier.
Read more >
python-websockets(1) - Arch manual pages
#!/usr/bin/env python import asyncio import websockets async def echo(websocket): ... We're using window.alert() for simplicity in this tutorial.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found