L
L
LakeForest2021-08-16 20:20:45
Python
LakeForest, 2021-08-16 20:20:45

How to properly write a websocket (or socket.io) in a microservice?

I would like to repeat the speech synthesis demo like here .
At first I thought to create a fastapi with a socket, and then I found out that it is possible to write a socket without a framework ...
What's better? And more correctly?

A separate front is planned, with which the api gateway will interact.
I would like such an example with a socket in order to clearly understand how, when it is worth doing ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Griboks, 2021-08-16
@LakeForest

You create a regular tcp socket, shake hands, transfer data in the required format. The rest depends on your preferences. Possible options:

  • Regular socket without third party libraries
  • Websocket library like websocket-client
  • Asynchronous websocket library like websockets
  • Your favorite framework like FastAPI
  • The library of the server you are going to communicate with, such as VoiceKit Python

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question