I have problem with re-connection method and get errors , Please guide me to solve this problem.
Node.js v: 10.14.2
Colyseus v: 0.11.15
Run on local machine
Server:
async onLeave (client, consented: boolean) {
//console.log("ChatRoom:", client.sessionId, "left!");
// flag client as inactive for other users
this.state.players[client.sessionId].connected = false;
try {
if (consented) {
throw new Error("consented leave");
}
// allow disconnected client to reconnect into this room until 20 seconds
await this.allowReconnection(client, 20);
// client returned! let's re-activate it.
this.state.players[client.sessionId].connected = true;
} catch (e) {
// 20 seconds expired. let's remove the client.
console.log('catch');
delete this.state.players[client.sessionId];
}
}
Client side:
function fun_recconection(){
console.log(room id ${roomPub.id} user id: ${roomPub.sessionId}
);
roomPub = client.reconnect(roomPub.id, roomPub.sessionId).then(room => {
console.log("joined successfully", room);
}).catch(e => {
console.error("join error", e);
});
}
I got below Errors when user want re-connection on server side:
(node:13296) UnhandledPromiseRejectionWarning: Error:
at Http2CallStream.call.on (D:\colyseus-examples\node_modules@grpc\grpc-js\build\src\client.js:96:45)
at Http2CallStream.emit (events.js:187:15)
at Http2CallStream.EventEmitter.emit (domain.js:441:20)
at process.nextTick (D:\colyseus-examples\node_modules@grpc\grpc-js\build\src\call-stream.js:71:22)
at process._tickCallback (internal/process/next_tick.js:61:11)
(node:13296) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:13296) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
lTQxdMuQe joined. rhvUnvD2e
(node:13296) UnhandledPromiseRejectionWarning: Error:
at Http2CallStream.call.on (D:\colyseus-examples\node_modules@grpc\grpc-js\build\src\client.js:96:45)
at Http2CallStream.emit (events.js:187:15)
at Http2CallStream.EventEmitter.emit (domain.js:441:20)
at process.nextTick (D:\colyseus-examples\node_modules@grpc\grpc-js\build\src\call-stream.js:71:22)
at process._tickCallback (internal/process/next_tick.js:61:11)
(node:13296) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 6)