Page 1 of 1

When clinet connecting again, there is a new ThreadPool..

Posted: 30 May 2018, 05:21
by crimsonfantasy
We detect client whether it is lose connection. If client lose connection, we use Sfsclient.connect again.
If connection is still not be establish, the job keep using Sfsclient.connect again.
We discover a Thread Pool created after using Sfsclient.connect.
So the worst situation is client program will be out of memory because there are so many Thread Pool that created by SfsClient in JVM.
Cloud you inspire me what is the explicit way to implement sfsclient reconnecting? No redundant thread pool existing .

Re: When clinet connecting again, there is a new ThreadPool..

Posted: 30 May 2018, 08:07
by Lapo
Hi,
when a client is disconnected you need to create a new SmartFox object so that the old one gets garbage collected.

To do this correctly you listen to the SFSEvent.CONNECTION_LOST and in the handler you remove all listeners before proceeding to create a new SmartFox instance.

Hope it helps

Re: When clinet connecting again, there is a new ThreadPool..

Posted: 31 May 2018, 02:02
by crimsonfantasy
Sorry, I known this is Java client forum here.
So does same methodology as Java to handle reconnecting when using JavaScript as client?
Thank you

Re: When clinet connecting again, there is a new ThreadPool..

Posted: 31 May 2018, 07:27
by Lapo
Yes, this applies to all supported API.

Cheers