<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[onAuth async Error (SOLVED)]]></title><description><![CDATA[<p>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.</p>
<p>The client-side error is:<br />
<code>Firefox can not establish a connection to the server at ws: // localhost: 8080 / BJlPioxfjG? Colyseusid = H1F7jl-9M &amp; channel = sah &amp; tocken = JbFDLDmpKLzx1LWxdTQNqdp09B8BmNc6maz0CGIOYPo3Ltnp1p + ojmOdpM6dwhB5 &amp; requestId = 1. colyseus.js: 1: 31 251 Possible causes: room's onAuth () failed or maxClients has been reached.</code></p>
<p><code>maxClients</code> I did not initialize it.</p>
<p>With verifyClient function it works perfect.</p>
<p>Code:</p>
<pre><code>async onAuth (options) {

        let authInst = new Auth();

        if (undefined != options.tocken &amp;&amp; !_.isEmpty(options.tocken)) {
            const response = await authInst.checkLogin(options.tocken, this.roomName);
            if (!_.isEmpty(response) &amp;&amp; !_.isEmpty(response[0]) &amp;&amp; !_.isEmpty(response[0].username)) {
                debug.infoRoomChat(&quot;onAuth: ok, tocken %O&quot;, options);
                return true;
            } else {
                debug.errorRoomChat(&quot;onAuth: invalid tocken %O&quot;, options);
                return false;
            }
        } else {
            debug.errorRoomChat(&quot;onAuth: undefined tocken %O&quot;, options);
        }
        return false;
    }
</code></pre>
<p>Thanks.</p>
]]></description><link>http://discuss.colyseus.io/topic/58/onauth-async-error-solved</link><generator>RSS for Node</generator><lastBuildDate>Fri, 06 Mar 2026 15:07:50 GMT</lastBuildDate><atom:link href="http://discuss.colyseus.io/topic/58.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 04 Apr 2018 07:27:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to onAuth async Error (SOLVED) on Thu, 05 Apr 2018 14:28:57 GMT]]></title><description><![CDATA[<p>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.</p>
<p>The client-side error is:<br />
<code>Firefox can not establish a connection to the server at ws: // localhost: 8080 / BJlPioxfjG? Colyseusid = H1F7jl-9M &amp; channel = sah &amp; tocken = JbFDLDmpKLzx1LWxdTQNqdp09B8BmNc6maz0CGIOYPo3Ltnp1p + ojmOdpM6dwhB5 &amp; requestId = 1. colyseus.js: 1: 31 251 Possible causes: room's onAuth () failed or maxClients has been reached.</code></p>
<p><code>maxClients</code> I did not initialize it.</p>
<p>With verifyClient function it works perfect.</p>
<p>Code:</p>
<pre><code>async onAuth (options) {

        let authInst = new Auth();

        if (undefined != options.tocken &amp;&amp; !_.isEmpty(options.tocken)) {
            const response = await authInst.checkLogin(options.tocken, this.roomName);
            if (!_.isEmpty(response) &amp;&amp; !_.isEmpty(response[0]) &amp;&amp; !_.isEmpty(response[0].username)) {
                debug.infoRoomChat(&quot;onAuth: ok, tocken %O&quot;, options);
                return true;
            } else {
                debug.errorRoomChat(&quot;onAuth: invalid tocken %O&quot;, options);
                return false;
            }
        } else {
            debug.errorRoomChat(&quot;onAuth: undefined tocken %O&quot;, options);
        }
        return false;
    }
</code></pre>
<p>Thanks.</p>
]]></description><link>http://discuss.colyseus.io/post/181</link><guid isPermaLink="true">http://discuss.colyseus.io/post/181</guid><dc:creator><![CDATA[rscata]]></dc:creator><pubDate>Thu, 05 Apr 2018 14:28:57 GMT</pubDate></item><item><title><![CDATA[Reply to onAuth async Error (SOLVED) on Invalid Date]]></title><description><![CDATA[<p>Hi <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/28">@rscata</a>,</p>
<p>Are you sure your <code>onAuth</code> is not returning <code>false</code>?</p>
<p>Can you confirm which version of Node.js are you using? We just discovered version 6 is not supported anymore.</p>
<p>Cheers</p>
]]></description><link>http://discuss.colyseus.io/post/182</link><guid isPermaLink="true">http://discuss.colyseus.io/post/182</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to onAuth async Error (SOLVED) on Thu, 05 Apr 2018 06:10:50 GMT]]></title><description><![CDATA[<p>Hi <a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/1">@endel</a></p>
<p>I put some console.log for debug.</p>
<pre><code>async onAuth (options) {

        console.log(1);

        let authInst = new Auth();

        if (undefined != options.tocken &amp;&amp; !_.isEmpty(options.tocken)) {
            console.log(2);
            const response = await authInst.checkLogin(options.tocken, this.roomName);
            if (!_.isEmpty(response) &amp;&amp; !_.isEmpty(response[0]) &amp;&amp; !_.isEmpty(response[0].username)) {
                console.log(3);           
                return true;
            } else {
                console.log(4);
                return false;
            }
        } else {
            console.log(5);
            debug.errorRoomChat(&quot;onAuth: undefined tocken %O&quot;, options);
        }
        console.log(6);
        return false;
    }
</code></pre>
<p>When it works well, the output is <strong>1,2 and 3</strong> , and when it does not work ok, the output is <strong>1 and 2</strong>.<br />
With the same user I tried, I just refreshed the page and sometimes work and sometimes not.</p>
<pre><code>checkLogin(tocken:string, roomName:string) {
// some validations

return new Promise((resolve, reject) =&gt; {
   // db query 

  // if ok 
  return resolve(result)

 // if err
  return reject(err)
}
}
</code></pre>
<p>With verifyClient function it works perfect.</p>
<p>I use v9.9.0 node version</p>
]]></description><link>http://discuss.colyseus.io/post/183</link><guid isPermaLink="true">http://discuss.colyseus.io/post/183</guid><dc:creator><![CDATA[rscata]]></dc:creator><pubDate>Thu, 05 Apr 2018 06:10:50 GMT</pubDate></item><item><title><![CDATA[Reply to onAuth async Error (SOLVED) on Invalid Date]]></title><description><![CDATA[<p>I found the problem. The problem was from me when I encode the token.</p>
<p>Sorry, and thank you</p>
]]></description><link>http://discuss.colyseus.io/post/184</link><guid isPermaLink="true">http://discuss.colyseus.io/post/184</guid><dc:creator><![CDATA[rscata]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to onAuth async Error (SOLVED) on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://discuss.colyseus.io/uid/28">@rscata</a> alright! One thing that is not intuitive in this version is that you can only see the error messages and stack traces if you turn on <code>DEBUG=colyseus:errors</code></p>
<pre><code>DEBUG=colyseus:errors npm start
</code></pre>
]]></description><link>http://discuss.colyseus.io/post/185</link><guid isPermaLink="true">http://discuss.colyseus.io/post/185</guid><dc:creator><![CDATA[endel]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>