Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

WebSocket protocol implementation for anyio

Project description


This library implements the WebSocket protocol based on the Sans-IO library wsproto. I/O is handled by the anyio project which makes this library compatible to asyncio, trio and curio.

Build Status Maintainability CodeFactor Documentation Status PyPI version


This library requires Python 3.5+. You can install it directly from PyPI:

python3 -m pip install -U anysocks

If you want the cutting edge development version instead, install it directly from GitHub:

python3 -m pip install -U git+


This README only provides a short overview, see the full documentation here.


import anyio
from anysocks import open_connection

async def main():
    async with open_connection('wss://') as con:
        print('Connection established!')

        # First, let's send some text to the server.
        text = input('What to send? ')
        await con.send_message(text)

        # Now, we receive and verify the server's response.
        message = await con.get_message()
        assert message == text, "Received {}, expected {}".format(message, text)

    print('Connection closed with code {}', con.close_code.value)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for anysocks, version 0.2.2
Filename, size File type Python version Upload date Hashes
Filename, size anysocks-0.2.2-py3-none-any.whl (11.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size anysocks-0.2.2.tar.gz (19.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page