<?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[re-connection field]]></title><description><![CDATA[<p>I have problem with re-connection method  and get errors , Please guide me to solve this problem.</p>
<p>Node.js v: 10.14.2<br />
Colyseus v: 0.11.15<br />
Run on local machine</p>
<p>Server:</p>
<pre><code>async onLeave (client, consented: boolean) {
    //console.log(&quot;ChatRoom:&quot;, client.sessionId, &quot;left!&quot;);
      // flag client as inactive for other users
        this.state.players[client.sessionId].connected = false;

        try {
            if (consented) {
                throw new Error(&quot;consented leave&quot;);
            }

            // 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];
        }
        
}
</code></pre>
<p>Client side:</p>
<p>function fun_recconection(){<br />
console.log(<code>room id ${roomPub.id} user id: ${roomPub.sessionId}</code>);<br />
roomPub = client.reconnect(<a href="http://roomPub.id" rel="nofollow">roomPub.id</a>, roomPub.sessionId).then(room =&gt; {<br />
console.log(&quot;joined successfully&quot;, room);<br />
}).catch(e =&gt; {<br />
console.error(&quot;join error&quot;, e);<br />
});<br />
}</p>
<p>I got below Errors when user want re-connection on server side:</p>
<p>(node:13296) UnhandledPromiseRejectionWarning: Error:<br />
at Http2CallStream.call.on (D:\colyseus-examples\node_modules@grpc\grpc-js\build\src\client.js:96:45)<br />
at Http2CallStream.emit (events.js:187:15)<br />
at Http2CallStream.EventEmitter.emit (domain.js:441:20)<br />
at process.nextTick (D:\colyseus-examples\node_modules@grpc\grpc-js\build\src\call-stream.js:71:22)<br />
at process._tickCallback (internal/process/next_tick.js:61:11)<br />
(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)<br />
(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.<br />
lTQxdMuQe joined.  rhvUnvD2e<br />
(node:13296) UnhandledPromiseRejectionWarning: Error:<br />
at Http2CallStream.call.on (D:\colyseus-examples\node_modules@grpc\grpc-js\build\src\client.js:96:45)<br />
at Http2CallStream.emit (events.js:187:15)<br />
at Http2CallStream.EventEmitter.emit (domain.js:441:20)<br />
at process.nextTick (D:\colyseus-examples\node_modules@grpc\grpc-js\build\src\call-stream.js:71:22)<br />
at process._tickCallback (internal/process/next_tick.js:61:11)<br />
(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)</p>
]]></description><link>http://discuss.colyseus.io/topic/295/re-connection-field</link><generator>RSS for Node</generator><lastBuildDate>Sun, 08 Mar 2026 20:47:16 GMT</lastBuildDate><atom:link href="http://discuss.colyseus.io/topic/295.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 18 Oct 2019 22:17:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to re-connection field on Fri, 18 Oct 2019 22:29:46 GMT]]></title><description><![CDATA[<p>I have problem with re-connection method  and get errors , Please guide me to solve this problem.</p>
<p>Node.js v: 10.14.2<br />
Colyseus v: 0.11.15<br />
Run on local machine</p>
<p>Server:</p>
<pre><code>async onLeave (client, consented: boolean) {
    //console.log(&quot;ChatRoom:&quot;, client.sessionId, &quot;left!&quot;);
      // flag client as inactive for other users
        this.state.players[client.sessionId].connected = false;

        try {
            if (consented) {
                throw new Error(&quot;consented leave&quot;);
            }

            // 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];
        }
        
}
</code></pre>
<p>Client side:</p>
<p>function fun_recconection(){<br />
console.log(<code>room id ${roomPub.id} user id: ${roomPub.sessionId}</code>);<br />
roomPub = client.reconnect(<a href="http://roomPub.id" rel="nofollow">roomPub.id</a>, roomPub.sessionId).then(room =&gt; {<br />
console.log(&quot;joined successfully&quot;, room);<br />
}).catch(e =&gt; {<br />
console.error(&quot;join error&quot;, e);<br />
});<br />
}</p>
<p>I got below Errors when user want re-connection on server side:</p>
<p>(node:13296) UnhandledPromiseRejectionWarning: Error:<br />
at Http2CallStream.call.on (D:\colyseus-examples\node_modules@grpc\grpc-js\build\src\client.js:96:45)<br />
at Http2CallStream.emit (events.js:187:15)<br />
at Http2CallStream.EventEmitter.emit (domain.js:441:20)<br />
at process.nextTick (D:\colyseus-examples\node_modules@grpc\grpc-js\build\src\call-stream.js:71:22)<br />
at process._tickCallback (internal/process/next_tick.js:61:11)<br />
(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)<br />
(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.<br />
lTQxdMuQe joined.  rhvUnvD2e<br />
(node:13296) UnhandledPromiseRejectionWarning: Error:<br />
at Http2CallStream.call.on (D:\colyseus-examples\node_modules@grpc\grpc-js\build\src\client.js:96:45)<br />
at Http2CallStream.emit (events.js:187:15)<br />
at Http2CallStream.EventEmitter.emit (domain.js:441:20)<br />
at process.nextTick (D:\colyseus-examples\node_modules@grpc\grpc-js\build\src\call-stream.js:71:22)<br />
at process._tickCallback (internal/process/next_tick.js:61:11)<br />
(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)</p>
]]></description><link>http://discuss.colyseus.io/post/1002</link><guid isPermaLink="true">http://discuss.colyseus.io/post/1002</guid><dc:creator><![CDATA[h4ss4n]]></dc:creator><pubDate>Fri, 18 Oct 2019 22:29:46 GMT</pubDate></item></channel></rss>