Error when many client bot do login.

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

Moderators: Lapo, Bax

truongps
Posts: 32
Joined: 27 Sep 2015, 17:06

Error when many client bot do login.

Postby truongps » 12 Jul 2016, 00:38

Hi,
I have a server. And I create 80 clients (write in Java) connect to server, login, join game room and play game. I have 80 clients but I see 65 current users on Dashboard. Please give me a hand.

When I run client I meet 2 errors:

Code: Select all

558 [Thread-175] ERROR sfs2x.client.core.sockets.TCPSocketLayer - TCPSocketLayer: Socket error: Connection reset by peer


Code: Select all

52898 [New I/O client worker #84-11] ERROR sfs2x.client.bitswarm.BitSwarmClient - ## BlueBox Error: Invalid BB session !


In my server, I meet:

Code: Select all

07:23:44,482 WARN  [qtp626871645-70] servlet.ServletHandler     - /BlueBox/BlueBox.do
java.lang.IllegalStateException: A session already exists with this id: b5be1644439117cb4c87fec5b478a0cc, Old session: {BBClient - { Id: 64, Type: BLUEBOX, Logged: No, IP: 127.0.0.1 }, b5be1644439117cb4c87fec5b478a0cc}
   at sfs2x.bluebox.v3.BBConnectionManager.addClient(BBConnectionManager.java:132)
   at sfs2x.bluebox.v3.SessionFilter.handleConnectionHandshake(SessionFilter.java:173)
   at sfs2x.bluebox.v3.SessionFilter.doFilter(SessionFilter.java:131)
   at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1615)
   at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:550)
   at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
   at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:568)
   at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221)
   at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1110)
   at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:479)
   at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)
   at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1044)
   at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
   at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:199)
   at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
   at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
   at org.eclipse.jetty.server.Server.handle(Server.java:459)
   at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:281)
   at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:232)
   at org.eclipse.jetty.io.AbstractConnection$1.run(AbstractConnection.java:505)
   at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:607)
   at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:536)
   at java.lang.Thread.run(Thread.java:745)


When all clients close application, the server through:

Code: Select all

07:26:53,903 WARN  [SocketWriter-1] core.SocketWriter     - java.lang.IllegalStateException: AsyncContext completed
   org.eclipse.jetty.server.AsyncContextState.state(AsyncContextState.java:47)
   org.eclipse.jetty.server.AsyncContextState.dispatch(AsyncContextState.java:114)
   org.eclipse.jetty.continuation.Servlet3Continuation.resume(Servlet3Continuation.java:139)
   sfs2x.bluebox.v3.data.BBClient.enqueueMessage(BBClient.java:80)
   com.smartfoxserver.bitswarm.core.SocketWriter.processBlueBoxSession(SocketWriter.java:242)
   com.smartfoxserver.bitswarm.core.SocketWriter.processSessionQueue(SocketWriter.java:208)
   com.smartfoxserver.bitswarm.core.SocketWriter.run(SocketWriter.java:181)
   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
   java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
   java.lang.Thread.run(Thread.java:745)
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Error when many client bot do login.

Postby Lapo » 12 Jul 2016, 07:22

It looks like your clients are having problems connecting via socket and resorting to http tunnel (BlueBox)
Make sure your clients can correctly reach the server's socket port before running the test.

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
truongps
Posts: 32
Joined: 27 Sep 2015, 17:06

Re: Error when many client bot do login.

Postby truongps » 12 Jul 2016, 09:24

All clients is the same code. 80 clients connect to server. But 65 clients connect OK. What happen to other clients when I run 80 clients at the same time?
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Error when many client bot do login.

Postby Lapo » 12 Jul 2016, 13:38

They are all connecting via HTTP from what I see but I don't think this is the test you want to run... clients will use sockets, no?
Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
truongps
Posts: 32
Joined: 27 Sep 2015, 17:06

Re: Error when many client bot do login.

Postby truongps » 12 Jul 2016, 15:13

Here is bot code. After a Bot connect Ok, it will send login to server.

Code: Select all

public static void main(String[] args) {
      Random random = new Random();
      int val = 0;
      BasicBot b = null;
      ArrayList<BotMain> botList = new ArrayList<>();
      for (int i = 0; i < 80; i++) {
         val = random.nextInt(3);
         if (val == 0) {
            b = new BasicBot(50, 25);
         } else if (val == 1) {
            b = new BasicBot(25, 50);
         } else {
            b = new BasicBot(0, 75);
         }
         BotMain botMain = new BotMain("test" + i, "123456", b);
         botMain.connect();
         botList.add(botMain);
      }
   }

   private BotMain(String username, String pass, BasicBot bot) {
      this.username = username;
      this.password = pass;
      this.bot = bot;
      this.smartFox = new SmartFox(false);
      // Add event listeners
      this.smartFox.addEventListener(SFSEvent.CONNECTION, this);
      this.smartFox.addEventListener(SFSEvent.CONNECTION_LOST, this);
      this.smartFox.addEventListener(SFSEvent.LOGIN, this);
      this.smartFox.addEventListener(SFSEvent.ROOM_JOIN, this);
      this.smartFox.addEventListener(SFSEvent.HANDSHAKE, this);
      this.smartFox.addEventListener(SFSEvent.USER_VARIABLES_UPDATE, this);
      this.smartFox.addEventListener(SFSEvent.EXTENSION_RESPONSE, this);
      Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
         
         @Override
         public void run() {
            synchronized (smartFox) {
               System.out.println("smartfox dis because application closed.");
               smartFox.disconnect();
               smartFox.killConnection();
            }
         }
      }));
   }
   

   private void connect() {
      this.smartFox.connect("127.0.0.1", 9933);
   }

   @Override
   public void dispatch(BaseEvent event) throws SFSException {
      if (event.getType().equalsIgnoreCase(SFSEvent.CONNECTION)) {
         this.onConnectEvent(event);
      } else if (event.getType().equalsIgnoreCase(SFSEvent.LOGIN)) {
         onLogin(event);
      } else if (event.getType().equalsIgnoreCase(SFSEvent.ROOM_JOIN)) {
         onJoinedRoom(event);
      } else if (event.getType().equalsIgnoreCase(SFSEvent.USER_VARIABLES_UPDATE)) {
         this.onUserVariableUpdate(event);
      } else {
         this.onGameResponse(event);
      }
   }
truongps
Posts: 32
Joined: 27 Sep 2015, 17:06

Re: Error when many client bot do login.

Postby truongps » 12 Jul 2016, 15:35

I run this code with 60 clients, It work OK without any error. Are there any setting around this?
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Error when many client bot do login.

Postby Lapo » 12 Jul 2016, 16:43

Can you please send us the log files of one session of your test?
You can zip the logs and send them to our support@... email box. Put also a reference to this discussion.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Malcolmtaify, Ronaldniff and 49 guests