Since I upgraded to 0.9.1 and I changed the verifyClient function to onAuth function, sometimes I need to try to connect to the server several times before I succeed.
The client-side error is:
Firefox can not establish a connection to the server at ws: // localhost: 8080 / BJlPioxfjG? Colyseusid = H1F7jl-9M & channel = sah & tocken = JbFDLDmpKLzx1LWxdTQNqdp09B8BmNc6maz0CGIOYPo3Ltnp1p + ojmOdpM6dwhB5 & requestId = 1. colyseus.js: 1: 31 251 Possible causes: room's onAuth () failed or maxClients has been reached.
maxClients
I did not initialize it.
With verifyClient function it works perfect.
Code:
async onAuth (options) {
let authInst = new Auth();
if (undefined != options.tocken && !_.isEmpty(options.tocken)) {
const response = await authInst.checkLogin(options.tocken, this.roomName);
if (!_.isEmpty(response) && !_.isEmpty(response[0]) && !_.isEmpty(response[0].username)) {
debug.infoRoomChat("onAuth: ok, tocken %O", options);
return true;
} else {
debug.errorRoomChat("onAuth: invalid tocken %O", options);
return false;
}
} else {
debug.errorRoomChat("onAuth: undefined tocken %O", options);
}
return false;
}
Thanks.