Address already in use, java.net.BindException: Address already in use]

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

Moderators: Lapo, Bax

bestDroid
Posts: 8
Joined: 11 Oct 2018, 17:01

Address already in use, java.net.BindException: Address already in use]

Postby bestDroid » 11 Oct 2018, 17:28

I have multiple instance of sfs2x on my centos server and I defined different port in each server.xml file. I also changed port number in http.ini and ssl.ini files but I am getting this error in log files.

>> Zone: DragDefault
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

20:54:12,117 INFO [main] managers.SFSRoomManager - Room created: { Zone: --=={{{ AdminZone }}}==-- }, [ Room: AdminRoom, Id: 0, Group: default, isGame: false ], type = SFSRoom
20:54:12,152 INFO [main] core.AdminToolService - AdminTool Service started
20:54:12,178 WARN [main] bootLogger - Was not able to bind socket: { 0.0.0.0:9930, (Tcp) }
20:54:12,180 WARN [main] bootLogger - Was not able to bind socket: { 127.0.0.1:9930, (Udp) }
20:54:12,186 ERROR [main] bootLogger - No bound sockets! Check the boot logs for possible problems!
20:54:12,192 INFO [SFSWorker:Sys:1] v2.SmartFoxServer - Listening Sockets:
20:54:12,193 INFO [SFSWorker:Sys:1] v2.SmartFoxServer -
_____ _____ _____ ___ __ __
| __| __| __| |_ | | |
|__ | __|__ | | _|- -|
|_____|__| |_____| |___|__|__|
_____ _____ _____ ____ __ __
| __ | __| _ | \| | |
| -| __| | | |_ _|
|__|__|_____|__|__|____/ |_|
[ 2.13.0 ]

20:54:12,193 INFO [SFSWorker:Sys:1] v2.SmartFoxServer - SmartFoxServer 2X (2.13.0) READY!
20:54:13,412 INFO [main] v3.SessionFilter - BlueBox-2X Service (3.1.0) READY.
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.jetty.start.Main.invokeMain(Main.java:214)
at org.eclipse.jetty.start.Main.start(Main.java:457)
at org.eclipse.jetty.start.Main.main(Main.java:75)
at com.smartfoxserver.v2.http.JettyServer.start(JettyServer.java:35)
at com.smartfoxserver.v2.SmartFoxServer.start(SmartFoxServer.java:321)
at com.smartfoxserver.v2.Main.main(Main.java:14)
Caused by: MultiException[java.net.BindException: Address already in use, java.net.BindException: Address already in use]
at org.eclipse.jetty.server.Server.doStart(Server.java:353)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1510)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1435)
... 10 more
Suppressed: java.net.BindException: Address already in use
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:317)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:235)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:390)
... 14 more
Caused by: java.net.BindException: Address already in use
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:317)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:235)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:390)
... 14 more



and get this error in boot.log file

11 Oct 2018 | 20:55:46,192 | INFO | main | bootLogger | | Session manager ready: com.smartfoxserver.bitswarm.sessions.DefaultSessionManager@1b45c0e
11 Oct 2018 | 20:55:46,198 | INFO | main | bootLogger | | TCP Selector opened
11 Oct 2018 | 20:55:46,203 | INFO | main | bootLogger | | UDP Selector opened
11 Oct 2018 | 20:55:46,205 | INFO | main | bootLogger | | AcceptSelector opened
11 Oct 2018 | 20:55:46,213 | INFO | main | bootLogger | | Added bound tcp socket --> 0.0.0.0:9931
11 Oct 2018 | 20:55:46,216 | INFO | main | bootLogger | | Added bound udp socket --> 127.0.0.1:9931
11 Oct 2018 | 20:55:46,217 | INFO | main | bootLogger | | Controller started: com.smartfoxserver.v2.controllers.v290.SystemReqController
11 Oct 2018 | 20:55:46,217 | INFO | Scheduler1-thread-1 | bootLogger | | Scheduler started: scheduler
11 Oct 2018 | 20:55:46,217 | INFO | main | bootLogger | | Controller started: com.smartfoxserver.v2.controllers.v290.ExtensionReqController
11 Oct 2018 | 20:55:46,217 | INFO | main | bootLogger | | Controller started: com.smartfoxserver.v2.controllers.v290.SmasherReqController
11 Oct 2018 | 20:55:46,218 | INFO | main | bootLogger | | Socket Writer started (pool size:3)
11 Oct 2018 | 20:55:46,218 | INFO | main | bootLogger | | Security Manager started
11 Oct 2018 | 20:55:46,220 | INFO | main | bootLogger | | DatagramReader started
11 Oct 2018 | 20:55:46,221 | INFO | main | bootLogger | | IOHandler: com.smartfoxserver.v2.protocol.SFSIoHandler@60410cd
11 Oct 2018 | 20:55:46,221 | INFO | main | bootLogger | | SocketReader started
11 Oct 2018 | 20:55:46,221 | INFO | main | bootLogger | | SocketAcceptor initialized
11 Oct 2018 | 20:55:46,221 | INFO | main | bootLogger | | [[[ ===--- Boot sequence complete ---=== ]]]
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Address already in use, java.net.BindException: Address already in use]

Postby Lapo » 12 Oct 2018, 07:06

Hi,
when this error occur it means another service is already using the TCP ports you want to use.
Make sure you don't have another service running on that port, including SFS2X. (i.e. there's a previous instance still running in the system)

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
bestDroid
Posts: 8
Joined: 11 Oct 2018, 17:01

Re: Address already in use, java.net.BindException: Address already in use]

Postby bestDroid » 12 Oct 2018, 15:13

I listed all port that start with 8 number by netstat command

[root@host /]# netstat -lnutp | grep ':8'
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3378/httpd
tcp6 0 0 :::8955 :::* LISTEN 12568/java
tcp6 0 0 :::8094 :::* LISTEN 11435/java
tcp6 0 0 :::8095 :::* LISTEN 12568/java
tcp6 0 0 :::8940 :::* LISTEN 10202/java
tcp6 0 0 :::8942 :::* LISTEN 8659/java
tcp6 0 0 :::8944 :::* LISTEN 2506/java
tcp6 0 0 :::8081 :::* LISTEN 10202/java
tcp6 0 0 :::8082 :::* LISTEN 8659/java
tcp6 0 0 :::8084 :::* LISTEN 2506/java
tcp6 0 0 :::8954 :::* LISTEN 11435/java

The ones that start with 80 I am using for http.ini and the one ones that start with 89 I am using for ssl.ini. Are these Ok?
bestDroid
Posts: 8
Joined: 11 Oct 2018, 17:01

Re: Address already in use, java.net.BindException: Address already in use]

Postby bestDroid » 12 Oct 2018, 15:21

I listed all service

tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 4146/master
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 3882/mysqld
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3374/httpd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3375/sshd
tcp6 0 0 :::8088 :::* LISTEN 2510/java
tcp6 0 0 :::8952 :::* LISTEN 2550/java
tcp6 0 0 :::9912 :::* LISTEN 2566/java
tcp6 0 0 :::8953 :::* LISTEN 2547/java
tcp6 0 0 :::9913 :::* LISTEN 2492/java
tcp6 0 0 ::1:25 :::* LISTEN 4146/master
tcp6 0 0 :::8091 :::* LISTEN 2525/java
tcp6 0 0 :::8092 :::* LISTEN 2550/java
tcp6 0 0 :::8093 :::* LISTEN 2547/java
tcp6 0 0 :::9920 :::* LISTEN 2525/java
tcp6 0 0 :::9921 :::* LISTEN 2547/java
tcp6 0 0 :::9900 :::* LISTEN 2510/java
tcp6 0 0 :::8943 :::* LISTEN 2555/java
tcp6 0 0 :::8944 :::* LISTEN 2569/java
tcp6 0 0 :::8945 :::* LISTEN 2530/java
tcp6 0 0 :::8946 :::* LISTEN 2566/java
tcp6 0 0 :::8083 :::* LISTEN 2555/java
tcp6 0 0 :::8947 :::* LISTEN 2492/java
tcp6 0 0 :::8948 :::* LISTEN 2510/java
tcp6 0 0 :::8084 :::* LISTEN 2569/java
tcp6 0 0 :::8085 :::* LISTEN 2530/java
tcp6 0 0 :::21 :::* LISTEN 3384/vsftpd
tcp6 0 0 :::8086 :::* LISTEN 2566/java
tcp6 0 0 :::9942 :::* LISTEN 2555/java
tcp6 0 0 :::9910 :::* LISTEN 2569/java
tcp6 0 0 :::22 :::* LISTEN 3375/sshd
tcp6 0 0 :::8087 :::* LISTEN 2492/java
tcp6 0 0 :::8951 :::* LISTEN 2525/java
tcp6 0 0 :::9911 :::* LISTEN 2530/java
udp 0 0 127.0.0.1:323 0.0.0.0:* 942/chronyd
udp6 0 0 ::1:323 :::* 942/chronyd
udp6 0 0 127.0.0.1:9900 :::* 2510/java
udp6 0 0 127.0.0.1:9910 :::* 2569/java
udp6 0 0 127.0.0.1:9911 :::* 2530/java
udp6 0 0 127.0.0.1:9912 :::* 2566/java
udp6 0 0 127.0.0.1:9913 :::* 2492/java
udp6 0 0 127.0.0.1:9920 :::* 2525/java
udp6 0 0 127.0.0.1:9921 :::* 2547/java
udp6 0 0 127.0.0.1:9942 :::* 2555/java

The ones that start with 99 I am using for server.xml file in config folder
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Address already in use, java.net.BindException: Address already in use]

Postby Lapo » 17 Oct 2018, 09:42

Ouch! So many ports to manage :shock:
It looks like a port management hell to me...

What's the advantage of complicating your life like this, when one server can run multiple apps anyways?

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
bestDroid
Posts: 8
Joined: 11 Oct 2018, 17:01

Re: Address already in use, java.net.BindException: Address already in use]

Postby bestDroid » 21 Oct 2018, 12:47

Hi,
Yes you are right but, because of user limitation I had to add multiple instance for each game and move user to other instance in case of reaching to limitation.
Do you have any idea about my problem?
bestDroid
Posts: 8
Joined: 11 Oct 2018, 17:01

Re: Address already in use, java.net.BindException: Address already in use]

Postby bestDroid » 21 Oct 2018, 12:49

Something i forgot to say is that I get this error when I run ./sfs2x.sh file
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Address already in use, java.net.BindException: Address already in use]

Postby Lapo » 21 Oct 2018, 16:20

Maybe you should consider buying a license for more than 100 users? :)
If don't think you can afford a perpetual license you can take a look into the Elastic Licenses which are super affordable and can be scaled up or down (in terms of CCU) at any time.

https://www.smartfoxserver.com/buy/sfs2x#p=elastic

As regards your specific problem, it looks like there's some port conflict, but given the number of instances you're trying to run on the same server it's getting complicated to manage them correctly, and it's easy to make mistakes.
Lapo

--

gotoAndPlay()

...addicted to flash games
bestDroid
Posts: 8
Joined: 11 Oct 2018, 17:01

Re: Address already in use, java.net.BindException: Address already in use]

Postby bestDroid » 27 Oct 2018, 11:03

Thanks for your reply,

Already we have a 2000 CCU license. Is it possible to manage more then 2000 CCU in one instance? In my situation I have 4 online game and I cant run all of them in one instance because of CCU limitation. If I create 4 zone for each game, Can each zone have 2000 CCU?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Address already in use, java.net.BindException: Address already in use]

Postby Lapo » 27 Oct 2018, 15:00

In my situation I have 4 online game and I cant run all of them in one instance because of CCU limitation. If I create 4 zone for each game, Can each zone have 2000 CCU?

You can use as many zones as you want but the CCU limit is global for the whole server.
Maybe you could take a look at our Elastic licenses which are very affordable:
https://www.smartfoxserver.com/buy/sfs2x#p=elastic

hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 78 guests