Here's the code:
const app = express()
const server = http.createServer(app)
const io = new Server(server, {
cors: {
origin: "*",
methods: ["PUT", "GET", "POST", "DELETE", "OPTIONS"],
}
})
io.on('connection', socket => socket.emit('message', 'well hello there'))
server.listen(APP_PORT, APP_HOST, () => {
console.log(`Listening on ${APP_HOST}:${APP_PORT}`)
})
Nothing special on the client side:
const socket = io(url)
...
socket.connect()
When I connect, nothing but "probes" (those 2probe 3probe things) and digits shows up in web debugger.
However if I add some significant delay on server side like this
io.on('connection', socket => setTimeout(() => socket.emit('message', 'well hello there'), 500))
everything "works" - client is now able to receive the message (small timeouts below ~350ms are not working btw).
Why is this happening? Any ideas?