SFS2x v2.13.5 disconnecting users

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

etonev777
Posts: 40
Joined: 08 Jan 2014, 08:21

SFS2x v2.13.5 disconnecting users

Postby etonev777 » 15 May 2019, 13:46

Hi, i recently updated the server to patch 2.13.5 and i have this problem that on every several days the server starts dropping a large amount of users and it is doing this until i restart it. I am not sure if the connections are not closed after the user leaves and the server pool reaches its limits or something else.
I got this error:
jetty.server.AbstractConnector | |
java.io.IOException: Too many open files
at sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method)
at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:422)
at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:250)
at org.eclipse.jetty.server.ServerConnector.accept(ServerConnector.java:373)
at org.eclipse.jetty.server.AbstractConnector$Acceptor.run(AbstractConnector.java:593)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
at java.lang.Thread.run(Thread.java:745)
And after it it starts not recognizing the extensions, dropping users etc.
Please help.
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFS2x v2.13.5 disconnecting users

Postby Lapo » 15 May 2019, 14:03

Hi,
this error isn't connected to the version of SmartFoxServer, but rather to the config of your OS.
Specifically you need to configure a higher number of file descriptors to allow for more connections.

This should work on any Debian and derivate (Ubuntu, Mint etc...)
1) Modify /etc/systemd/user.conf and /etc/systemd/system.conf with the following line:

Code: Select all

DefaultLimitNOFILE=65535


2) Modify /etc/security/limits.conf with the following lines:

Code: Select all

username hard nofile 65535
username soft nofile 65535


Taken from:
https://superuser.com/questions/1200539 ... 18#1200818

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
etonev777
Posts: 40
Joined: 08 Jan 2014, 08:21

Re: SFS2x v2.13.5 disconnecting users

Postby etonev777 » 15 May 2019, 15:09

I will do this, but i think the problem is something else, since it didn't make such problems before and the configuration is not changed. Also i checked and the limit for opened files is 1024 (open files 1024). At the same time the number of users online at the same is maximum 400 at this time. I am afraid that i will enlarge the opened fies number and this will happen again only in a longer period of time.
etonev777
Posts: 40
Joined: 08 Jan 2014, 08:21

Re: SFS2x v2.13.5 disconnecting users

Postby etonev777 » 15 May 2019, 17:11

This is what i read, so i don't think the best solution is just to increase the number of files.
There are two typical solutions to it:

1)Check your application logic and make sure it is not opening too many files unnecessarily (for example, In a loop there is file open, but it is not getting closed anywhere)
2)Increase the open files limit on your system.

Don’t just blindly go with solution #2 and increase the total number of open files without understanding exactly what your application does, and how many files you are expecting the application to open.
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFS2x v2.13.5 disconnecting users

Postby Lapo » 16 May 2019, 06:53

etonev777 wrote:I will do this, but i think the problem is something else, since it didn't make such problems before and the configuration is not changed. Also i checked and the limit for opened files is 1024 (open files 1024). At the same time the number of users online at the same is maximum 400 at this time. I am afraid that i will enlarge the opened fies number and this will happen again only in a longer period of time.

There can be very few doubts about the cause of the problem, I can assure you. The error message is very clear and unambiguous.

Keep in mind that 1024 is the total amount of allowed file descriptors (files + socket connections) available for all processes of the specific user. This means that 400 SFS connections must be added to all other connections and open files in the system. You can see why a limit of 1024 is indeed not enough for a live server.

Once you set it to a much higher value (such as 65535) the error will disappear for good.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFS2x v2.13.5 disconnecting users

Postby Lapo » 16 May 2019, 06:54

etonev777 wrote:This is what i read, so i don't think the best solution is just to increase the number of files.
There are two typical solutions to it:

1)Check your application logic and make sure it is not opening too many files unnecessarily (for example, In a loop there is file open, but it is not getting closed anywhere)
2)Increase the open files limit on your system.

Don’t just blindly go with solution #2 and increase the total number of open files without understanding exactly what your application does, and how many files you are expecting the application to open.

I don't understand this post. Are you replying to yourself?
Lapo

--

gotoAndPlay()

...addicted to flash games
etonev777
Posts: 40
Joined: 08 Jan 2014, 08:21

Re: SFS2x v2.13.5 disconnecting users

Postby etonev777 » 16 May 2019, 16:45

Sorry, i am not replying to myself but made a mistake in the sentence. I wanted to say that i want to understand why this number of open files is increasing and reaching over 1024 although it is a small number of opened files like you said. But for example yesterday i checked for opened files by java and the number was 476, today with the same number of users it is 739. So i think there is a leak somewhere. In some cases the files are not closed and they are becoming bigger and bigger number. If i set the number of open files to unlimited this number can become much bigger, i am not sure if this is OK for the server health.
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFS2x v2.13.5 disconnecting users

Postby Lapo » 17 May 2019, 07:47

etonev777 wrote:Sorry, i am not replying to myself but made a mistake in the sentence. I wanted to say that i want to understand why this number of open files is increasing and reaching over 1024 although it is a small number of opened files like you said. But for example yesterday i checked for opened files by java and the number was 476, today with the same number of users it is 739. So i think there is a leak somewhere. In some cases the files are not closed and they are becoming bigger and bigger number. If i set the number of open files to unlimited this number can become much bigger, i am not sure if this is OK for the server health.


The file limit is not just for java is for all processes run by the same user. Increasing the file descriptors is the correct way to solve your problem and it's not going to affect the server health. On the contrary it will help it to work correctly.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
etonev777
Posts: 40
Joined: 08 Jan 2014, 08:21

Re: SFS2x v2.13.5 disconnecting users

Postby etonev777 » 17 May 2019, 12:15

Thank you for the reply, but i still don't understand why is this number of opened files permanently increasing. I am listing only files that Java opens and the number is increasing every day. That doesn't seems OK. I know that the DefaultLimitNOFILE settings is for all processes but i am checking the number of files opened by JAVA only(by the SFS2X) and this number is increasing every day. I am not sure if there is a problem in my extensions or in the last version of the SFS2X but this is certainly not OK.
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFS2x v2.13.5 disconnecting users

Postby Lapo » 17 May 2019, 13:48

Show us the list of open files.
Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 129 guests