Answer the question
In order to leave comments, you need to log in
How can I return the result from container 1 to a socket on container 2?
I want to establish a connection in the form of a chat in the demo version of the application. the user sends text, the socket receives and passes to another container, where the request can be processed for a long time. At the same time, the download icon hangs in the user's chat. If the user waited for a response, the socket connection is still working, then how the n-container finished processing the message - I want to send a response to the user's chat.
But I don’t understand how I can return the answer to this particular chat (socket connection). Conditional code:
# в container1
@app.post('/syth')
def syth(text):
mel = [1,2,3]
bytes_audio=[0,1,0,0,0]
# отправить результат в container1
send("wss://container1:8081/ws", bytes_audio) #### Или как???
# в container2
def gateway(data):
check_data()
post("http://container2:8080/syth", data)
# в container1
@app.websocket("/ws")
async def websocket_endpoint(websocket: WebSocket):
await websocket.accept()
while True:
data = await websocket.receive_text()
await gateway(data) #отправил запрос
await websocket.send_text(f"wait audio: {data}")
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question