Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
SocketIO is 20 seconds late

I'm trying to connect my backend (python, flask) and frontend (react) with sockets, but the every time the sockets are around 20 seconds late.

backend:

from flask_socketio import SocketIO, emit
from flask import Flask
from flask_cors import CORS

app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret!'
socketio = SocketIO(app, cors_allowed_origins="*")
CORS(app)

socketio.emit('message', 'test')

if __name__ == '__main__':
    socketio.run(app, debug=True, host='0.0.0.0')

frontend:

const App = () => {

    const [message, setMessage] = useState("")

    useEffect(() => {
        const socket = io('http://localhost:5000')
        socket.on("message", data => {
            setMessage(data)
        })
    }, [])

    return (
        <div>
            {message}
        </div>
    )
}

So the word test appears 20 seconds after loading the page. Why? Is it possible to do it faster?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!