No timeouts on websocket receive
nevercast opened this issue ยท 1 comments
Versions:
- Minecraft: 1.12.2
- CC: Tweaked: 1.82.2
- Modpack: FTB Ultimate Reloaded
Reproduction steps
- Create a websocket server that does not reply
- Connect to server in CC
- Call
ws.receive()
- Wait forever
- Observe that CC will never return
- Close server
- Observe that CC is still waiting to receive, even though the server is closed.
Implement
There needs to be a websocket_timeout event I believe, and this needs to be captured in the receive function, the receive function should also take an optional timeout argument.
I do believe there is already a websocket_close event, but it seems that websocket.receive does not wait for it. It should.
Similar things could be said for send() I imagine, but I don't have a producible issue there.
Regarding creating a websocket server that does not reply. Here is a minimal setup.
- Install Node.js
- Create a directory somewhere for a project, change in to that directory
npm i ws
- Create
index.js
and add this source:
const ws = require('ws')
const wss = new ws.Server({
host: '0.0.0.0',
port: 80
}, () => console.log('server started'))
.on('connection', (client) => {
console.log('client connected')
client.on('close', (code, reason) => {
console.log('client disconnected', code, reason)
}).on('message', (msg) => {
console.log('message', msg)
})
})
.on('error', (error) => console.log('server error', error))
- Run server
node index.js
On the client side, just connect, and then receive.