websocket

Flask: How to update values on a web page

Flask: How to update values on a web page Question: I have the following code: app = Flask(__name__) @app.route("/") def Tracking(): lower = np.array([35, 192, 65]) upper = np.array([179, 255, 255]) video = cv2.VideoCapture(1, 0) times = [] total = 0 is_round = False while True: success, img = video.read() image = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) mask …

Total answers: 1

Websocket Json Data to DataFrame

Websocket Json Data to DataFrame Question: I am learning how to work with APIs and web sockets in finance. My goal for this code is to access data and create a DataFrame with only columns (index, ask, bid & quote) I have tried appending values to the DataFrame but it creates a new DataFrame every …

Total answers: 1

Two websockets with BinanceSocketManager

Two websockets with BinanceSocketManager Question: I’m trying to open two web sockets – depth book and user socket. Here’s my code: async def sockets(client): bm = BinanceSocketManager(client) ds = bm.depth_socket("BTCUSDT", depth=BinanceSocketManager.WEBSOCKET_DEPTH_5) print("Started…") async with ds as depth_socket: while True: res = await depth_socket.recv() print(res) await client.close_connection() I need bm.user_socket() socket to be opened as well …

Total answers: 2

Websocket getting closed immediately after connecting to FastAPI Endpoint

Websocket getting closed immediately after connecting to FastAPI Endpoint Question: I’m trying to connect a websocket aiohttp client to a fastapi websocket endpoint, but I can’t send or recieve any data because it seems that the websocket gets closed immediately after connecting to the endpoint. server import uvicorn from fastapi import FastAPI, WebSocket app = …

Total answers: 1

Real time chat application with Django Channels

Real time chat application with Django Channels Question: My real time chat application refuses to send message. no errors at all. I have tried tracing the errors by logging to the console at every stage passed and also tried printing to the terminal. I think the problem might be from consumers.py here is my consummers.py …

Total answers: 2

Proper way to cancel remaining trio nursery tasks inside fastAPI websocket?

Proper way to cancel remaining trio nursery tasks inside fastAPI websocket? Question: I’m still quite new to websockets and I’ve been given a problem I’m having a hard time solving. I need to build a websocket endpoint with FastAPI in which a group of tasks are run asynchronously (to do so I went with trio) …

Total answers: 1

Python websockets keepalive ping timeout; no close frame received

Python websockets keepalive ping timeout; no close frame received Question: I have 20-50 users from whom I want real-time information about whether they are connected to the Internet or have a weak Internet I wrote a Python script that checks the connection and sends the information to the web server in Django django-channels script run …

Total answers: 1

Binance Websocket client stops after a while

Binance Websocket client stops after a while Question: I am working on Binance Websocket to listen to account events MARKET events. I copy every order from masters to salve it works just fine when I run it and it copies from all master. However, when I run it in background using nohup Linux service it …

Total answers: 3

Implement a Python WebSocket listener without async/asyncio

Implement a Python WebSocket listener without async/asyncio Question: I’m running a websocket listener in a separate thread. I’d like to connect to the websocket then do: while True: msg = sock.wait_for_message() f(msg) i.e. no async/asyncio Is this stupid? Is there a way to do this? Asked By: P i || Source Answers: In absence of …

Total answers: 2

FastAPI websocket connection causes cpu spike to 100% inside the docker container

FastAPI websocket connection causes cpu spike to 100% inside the docker container Question: I am developing a private chat for two or more users to communicate with each other. I have an endpoint for the websocket connection where only authenticated users are able to do a handshake between client and the server The problem occurs …

Total answers: 2