socket.io
socket.io copied to clipboard
When a send a big data to server, I can't get 413 error by listen ‘disconnect’ event
socket.io: 4.6.1 socket.io-client: 4.6.1
Hi! You can use the second argument of the disconnect event:
socket.on("disconnect", (reason, details) => {
console.log(reason); // "transport error"
// in that case, details is an error object
console.log(details.message); "xhr post error"
console.log(details.description); // 413 (the HTTP status of the response)
// details.context refers to the XMLHttpRequest object
console.log(details.context.status); // 413
console.log(details.context.responseText); // ""
});
I think this can be closed now. Please reopen if needed.
Tanks for your answer, but when i listen 'disconnect' event, i only get detail message is
{
"description": "websocket connection closed",
"context": {
"isTrusted":true
}
}
Only listen 'error' message can get the 413 error, But need to reconnect several times to get the corresponding error。
{
"description":413,
"context":{},
"type":"TransportError"
}