How do I use Azure Web PubSub for Socket.io in python backend?

Vinod Kumar 25 Reputation points
2024-05-25T03:25:15.0433333+00:00

How do I use Azure Web PubSub for Socket.io in python backend? I am using FastAPI for my backend.

I could only find javascript sdk & code samples in the documentation. Eg: https://learn.microsoft.com/en-us/azure/azure-web-pubsub/socketio-quickstart

Is there a python sdk for Azure PubSub for Socket.io?

I know there's a python sdk for the non-socket.io version. I don't know if it can be used for socket.io

Azure Web PubSub
Azure Web PubSub
An Azure service that provides real-time messaging for web applications using WebSockets and the publish-subscribe pattern.
78 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Gowtham CP 5,210 Reputation points
    2024-05-25T04:00:55.7+00:00

    Hello Vinod Kumar ,

    Thanks for reaching out in the Microsoft Q&A!

    While there isn't a separate Python SDK specifically for Azure Web PubSub with Socket.IO, you can leverage the Azure Web PubSub Python SDK alongside the websockets library. First, install the dependencies using pip install azure-webpubsub websockets[wamp]. Obtain your Azure Web PubSub connection string and store it securely. Create a FastAPI endpoint that handles WebSocket connections and use the azure-webpubsub library within the handler to connect to Azure Web PubSub, manage pub/sub operations, and send/receive messages. For further details, you can refer to the Python server SDK for Azure Web PubSub, the Quickstart guide for Web PubSub, and the WebSockets documentation.

    If you find this helpful, please accept this answer to close the thread. Thanks!


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.