Issue
I am currently using Python socket.io and aiohttp to make a Server. My client is a nodejs socket.io client. I have a thread which sends the current Time using the send function. The message from the connect event is received immediately but the messages from the Thread are only sent after the ping_timeout is reached. The log shows that the event was emitted before the timeout is reached. How do i achive that the thread immediatly sends the data, not after the timeout is reached.
Client.js
const { io } = require("socket.io-client");
const socket = io("http://127.0.0.1:8080/");
socket.on('message', (data) => {console.log(data)});
Server.py
from threading import Thread
from time import time
from aiohttp import web
import socketio, asyncio
sio = socketio.AsyncServer(ping_timeout=1, logger=True, engineio_logger=True)
app = web.Application()
sio.attach(app)
@sio.event
async def connect(sid, environ):
await sio.send('firstMessage')
async def sendLoop():
while(True):
await sio.send(f'DATA-{time()}')
await asyncio.sleep(0.5)
Thread(target=asyncio.run, args=(sendLoop(),),daemon=True).start()
web.run_app(app)
Log
78wfS8KVIE-JYJRrAAAA: Sending packet OPEN data {'sid': '78wfS8KVIE-JYJRrAAAA', 'upgrades': ['websocket'], 'pingTimeout': 1000, 'pingInterval': 25000}
78wfS8KVIE-JYJRrAAAA: Received packet MESSAGE data 0
emitting event "message" to all [/]
78wfS8KVIE-JYJRrAAAA: Sending packet MESSAGE data 2["message","firstMessage"]
78wfS8KVIE-JYJRrAAAA: Received request to upgrade to websocket
78wfS8KVIE-JYJRrAAAA: Sending packet MESSAGE data 0{"sid":"etNjKTKYnMWTk3NHAAAB"}
78wfS8KVIE-JYJRrAAAA: Upgrade to websocket successful
emitting event "message" to all [/]
78wfS8KVIE-JYJRrAAAA: Sending packet MESSAGE data 2["message","DATA-1646390154.3194933"]
emitting event "message" to all [/]
78wfS8KVIE-JYJRrAAAA: Sending packet MESSAGE data 2["message","DATA-1646390154.8345013"]
As the loggin only Prints to console there is no timestamp. The connection process however was <1s
Update
The problem was solved when switching from Python 3.9 to 3.7.3
Solution
The problem was solved when switching from Python 3.9 to 3.7.3
Answered By - NoSuchUser
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.