Not getting login request on LoginHandler

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

Moderators: Lapo, Bax

sitnik
Posts: 19
Joined: 24 Jan 2018, 08:49

Not getting login request on LoginHandler

Postby sitnik » 23 May 2020, 15:25

Greetings :D

i am making a basic game from scratch.
Both server extension and client are written in Java.

i am able to connect, but on connection success when i send Login request, i do not get any response and after 30 seconds connection lost event triggers on client side, also on the server side the Loginhandler class is not getting triggered.

kIndly help, stuck on this from 2 weeks :?

Code: Select all

SFS server version 2.14.0
jdk 1.8
jre 1.8
Win 7 Pro


smartfox server logs on connection and login request

Code: Select all


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 >> Zone: Uno
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

23 May 2020 | 19:38:26,075 | INFO  | main | entities.managers.SFSRoomManager |     | Room created: { Zone: Uno }, [ Room: The Lobby, Id: 0, Group: default, isGame: false ], type = SFSRoom
23 May 2020 | 19:38:26,106 | INFO  | main | Extensions |     | {MyGame}: UnoGameLobby initialized
23 May 2020 | 19:38:26,137 | INFO  | main | entities.managers.SFSRoomManager |     | Room created: { Zone: --=={{{ AdminZone }}}==-- }, [ Room: AdminRoom, Id: 1, Group: default, isGame: false ], type = SFSRoom
23 May 2020 | 19:38:26,449 | INFO  | main | v2.core.AdminToolService |     | AdminTool Service started
23 May 2020 | 19:38:27,167 | INFO  | SFSWorker:Sys:1 | smartfoxserver.v2.SmartFoxServer |     | Listening Sockets: { 127.0.0.1:9933, (Tcp) } { 127.0.0.1:9933, (Udp) }
23 May 2020 | 19:38:27,167 | INFO  | SFSWorker:Sys:1 | smartfoxserver.v2.SmartFoxServer |     | 
 _____ _____ _____    ___ __ __
|   __|   __|   __|  |_  |  |  |
|__   |   __|__   |  |  _|-   -|
|_____|__|  |_____|  |___|__|__|                                         
 _____ _____ _____ ____  __ __
| __  |   __|  _  |    \|  |  |
|    -|   __|     |  |  |_   _|
|__|__|_____|__|__|____/  |_| 
[ 2.14.0 ]

23 May 2020 | 19:38:27,167 | INFO  | SFSWorker:Sys:1 | smartfoxserver.v2.SmartFoxServer |     | SmartFoxServer 2X (2.14.0) READY!
23 May 2020 | 19:38:37,535 | INFO  | main | tomcat.bluebox.BBSessionFilter |     | BlueBox Service (4.0.0) READY.
23 May 2020 | 19:39:44,545 | INFO  | SocketReader | bitswarm.sessions.DefaultSessionManager |     | Session created: { Id: 1, Type: DEFAULT, Logged: No, IP: 127.0.0.1:49584 } on Server port: 9933 <---> 49584
23 May 2020 | 19:40:17,212 | INFO  | Scheduler1-thread-1 | bitswarm.sessions.DefaultSessionManager |     | Session removed: { Id: 1, Type: DEFAULT, Logged: No, IP: 127.0.0.1:49584 }




client side consoles, no login success or error revived only connection_lost hits after 30 that too secs
log4j:WARN No appenders could be found for logger (game).
log4j:WARN Please initialize the log4j system properly.
Initialised base bot
Add sfs base bot listeners
connecting sfs

sending login to sfs



connection lost



This is how my backend Zone extension init method looks like:

Code: Select all

public void init() {

      try
      {
         addEventHandler(SFSEventType.USER_LOGIN, UnoUserLoginHandler.class);
         addEventHandler(SFSEventType.USER_JOIN_ZONE, UnoLobbyJoinHandler.class);
         
         trace("UnoGameLobby initialized");
         
                  
      }
      catch (Exception e)
      {
         logger.error("GameLobby init exception",e);
      }
      
   }

This zone extension gets loaded properly in sfs and i am receiving console as well
UnoGameLobby initialized


My Login handler class

Code: Select all


public  class UnoUserLoginHandler extends BaseServerEventHandler{
   @Override
   public  void handleServerEvent(ISFSEvent arg0) throws SFSException
   {
      
      try
      {
         trace("################UnoUserLoginHandler handleServerEvent starts");
         
         String name = (String) arg0.getParameter(SFSEventParam.LOGIN_NAME);
         String pwd  = (String) arg0.getParameter(SFSEventParam.LOGIN_PASSWORD);
      
      }
      catch (Exception e)
      {
         trace("UnoUserLoginHandler Exception"+e);
      }
   }
}



My Zone config xml looks like this, improtant ones only, attaching complete xml with the post as well

Code: Select all

<zone>
  <name>Uno</name>
  <isCustomLogin>true</isCustomLogin>
  <isForceLogout>true</isForceLogout>
<!--  <isEncrypted>false</isEncrypted> -->
  <maxUsers>1000</maxUsers>
  <maxUserVariablesAllowed>10</maxUserVariablesAllowed>
  <maxRoomVariablesAllowed>10</maxRoomVariablesAllowed>
  <minRoomNameChars>1</minRoomNameChars>
  <maxRoomNameChars>20</maxRoomNameChars>
  <maxRooms>500</maxRooms>
  <maxRoomsCreatedPerUser>10</maxRoomsCreatedPerUser>
  <overrideMaxUserIdleTime>120</overrideMaxUserIdleTime>
  <maxFailedLogins>2</maxFailedLogins>
  <allowGuestUsers>true</allowGuestUsers>
  <guestUserNamePrefix>UnoPlayer#</guestUserNamePrefix>
 
  <defaultPlayerIdGeneratorClass></defaultPlayerIdGeneratorClass>
  <geoLocationEnabled>true</geoLocationEnabled>
 
  <rooms>
    <room>
      <name>The Lobby</name>
      <groupId>default</groupId>
      <password></password>
      <maxUsers>150</maxUsers>
      <maxSpectators>0</maxSpectators>
      <isDynamic>false</isDynamic>
      <isGame>false</isGame>
      <isHidden>false</isHidden>
      <autoRemoveMode>DEFAULT</autoRemoveMode>
      <permissions>
        <flags>PUBLIC_MESSAGES</flags>
        <maxRoomVariablesAllowed>10</maxRoomVariablesAllowed>
      </permissions>
      <events>USER_ENTER_EVENT,USER_EXIT_EVENT,USER_COUNT_CHANGE_EVENT,USER_VARIABLES_UPDATE_EVENT</events>
      <badWordsFilter isActive="false"/>
      <roomVariables/>
      <extension>
        <name></name>
      <type></type>
      <file></file>
      <propertiesFile></propertiesFile>
      <reloadMode>AUTO</reloadMode>
      </extension>
    </room>
  </rooms>
 
 
  <extension>
    <name>MyGame</name>
    <type>JAVA</type>
    <file>sfs.extensions.UnoGameLobby</file>
    <propertiesFile></propertiesFile>
    <reloadMode>AUTO</reloadMode>
  </extension>
 
</zone>


Client side code looks like this

Code: Select all



public  class BotClient {

   protected SmartFox sfs = new SmartFox(true);
   protected LobbyEventListener eventListener = new LobbyEventListener();
   protected BasePrinter log = new BasePrinter();
   ConfigData config=null;
   private boolean useCrypto = false;
   
   protected int playerId=-1;
   protected String userName="";
   protected String passWord="";
   protected static String ip ="localhost";
   protected static String zoneName ="Uno";
   protected static int portNo =9933;
   protected static int encryptPortNo =8443;
   
   public static void main(String[] args) {
      BotClient client = new BotClient(ip,zoneName,portNo);      
   }
   
   public BotClient(String ip, String zoneName, int portNo) {
      this.ip=ip;
      this.zoneName=zoneName;
      this.portNo=portNo;
      init();
   }
   private void init()
   {
      log.print("Initialised base bot");
      addListeners();
      connect();
   }
   private void addListeners() {
      log.print("Add sfs base bot listeners");
      sfs.addEventListener(SFSEvent.CONNECTION, eventListener);
      sfs.addEventListener(SFSEvent.CONNECTION_LOST, eventListener);
      sfs.addEventListener(SFSEvent.LOGIN, eventListener);
      sfs.addEventListener(SFSEvent.LOGOUT, eventListener);
      sfs.addEventListener(SFSEvent.LOGIN_ERROR, eventListener);
      sfs.addEventListener(SFSEvent.ROOM_JOIN, eventListener);
      sfs.addEventListener(SFSEvent.ROOM_JOIN_ERROR, eventListener);
      sfs.addEventListener(SFSEvent.USER_EXIT_ROOM, eventListener);
      sfs.addEventListener(SFSEvent.CRYPTO_INIT, eventListener);
      sfs.addEventListener(SFSEvent.EXTENSION_RESPONSE, eventListener);
   }
   
   private void connect()
   {
      ConfigData config=new ConfigData();
      config.setHost(ip);
      config.setPort(portNo);
      config.setZone(zoneName);
      
      log.print("connecting sfs");
      if(useCrypto)
         sfs.connect(ip,encryptPortNo);
      else
         sfs.connect(config);
   }
   private void login()
   {
      if(useCrypto)
      {
         ISFSObject params = new SFSObject();
         params.putUtfString("password", passWord);
         sfs.send(new LoginRequest(userName, null, zoneName, params));
      }
      else
      {
         sfs.send(new LoginRequest(userName,passWord, zoneName));
      }
      log.print("sending login to sfs");

   }
   private void cryptoInit() {
      log.print("init crypto");
      sfs.initCrypto();
   }
   
   class LobbyEventListener implements IEventListener
   {
      @Override
      public void dispatch(BaseEvent evt) throws SFSException {

         switch (evt.getType())
         {
            case SFSEvent.CONNECTION:
            {
               boolean success=(Boolean)evt.getArguments().get("success");
               if(success)
               {
                  log.print("connection success");
                  if(!useCrypto)
                  {
                     login();
                  }
                  else
                  {
                     cryptoInit();   
                  }
               }
               else
               {
                  log.print("connection request failed");
               }
               
            }
            break;
            case SFSEvent.CONNECTION_LOST:
            {
               log.print("connection lost");
            }
            break;
            case SFSEvent.LOGIN:
            {
               log.print("login success");
            }
            break;
            case SFSEvent.LOGIN_ERROR:
            {
               log.print("login error");
            }
            break;
            case SFSEvent.USER_EXIT_ROOM:
            {
               log.print("user exit room");
            }
            break;
            case SFSEvent.ROOM_JOIN:
            {
               log.print("room join");
            }
            break;
            case SFSEvent.ROOM_JOIN_ERROR:
            {
               log.print("room join error");
            }
            break;
            case SFSEvent.CRYPTO_INIT:
            {
               log.print("crypto init");
               login();
            }
            break;
            case SFSEvent.LOGOUT:
            {
               log.print("logout success");
            }
            break;
         }
      }
   }
}




detailed zone xml file

Code: Select all

<zone>
  <name>Uno</name>
  <isCustomLogin>true</isCustomLogin>
  <isForceLogout>true</isForceLogout>
  <applyWordsFilterToUserName>true</applyWordsFilterToUserName>
  <applyWordsFilterToRoomName>true</applyWordsFilterToRoomName>
  <applyWordsFilterToPrivateMessages>true</applyWordsFilterToPrivateMessages>
  <isFilterBuddyMessages>true</isFilterBuddyMessages>
<!--  <isEncrypted>false</isEncrypted> -->
  <maxUsers>1000</maxUsers>
  <maxUserVariablesAllowed>10</maxUserVariablesAllowed>
  <maxRoomVariablesAllowed>10</maxRoomVariablesAllowed>
  <minRoomNameChars>1</minRoomNameChars>
  <maxRoomNameChars>20</maxRoomNameChars>
  <maxRooms>500</maxRooms>
  <maxRoomsCreatedPerUser>10</maxRoomsCreatedPerUser>
  <userCountChangeUpdateInterval>1000</userCountChangeUpdateInterval>
  <userReconnectionSeconds>15</userReconnectionSeconds>
  <overrideMaxUserIdleTime>120</overrideMaxUserIdleTime>
  <maxFailedLogins>2</maxFailedLogins>
  <allowGuestUsers>true</allowGuestUsers>
  <guestUserNamePrefix>UnoPlayer#</guestUserNamePrefix>
  <publicRoomGroups>default,games,chats</publicRoomGroups>
  <defaultRoomGroups>default,games,chats</defaultRoomGroups>
  <defaultPlayerIdGeneratorClass></defaultPlayerIdGeneratorClass>
  <allowInvitationsOnlyForBuddies>true</allowInvitationsOnlyForBuddies>
  <maxUsersPerJoinInvitationRequest>5</maxUsersPerJoinInvitationRequest>
  <geoLocationEnabled>true</geoLocationEnabled>
  <wordsFilter active="false">
    <useWarnings>false</useWarnings>
    <warningsBeforeKick>3</warningsBeforeKick>
    <kicksBeforeBan>2</kicksBeforeBan>
    <banDuration>1440</banDuration>
    <maxBadWordsPerMessage>0</maxBadWordsPerMessage>
    <kicksBeforeBanMinutes>3</kicksBeforeBanMinutes>
    <secondsBeforeBanOrKick>5</secondsBeforeBanOrKick>
    <warningMessage>Stop swearing or you will be banned</warningMessage>
    <kickMessage>Swearing not allowed: you are being kicked</kickMessage>
    <banMessage>Too much swearing: you are banned</banMessage>
    <wordsFile>config/wordsFile.txt</wordsFile>
    <filterMode>BLACKLIST</filterMode>
    <banMode>NAME</banMode>
    <hideBadWordWithCharacter>*</hideBadWordWithCharacter>
  </wordsFilter>
  <floodFilter active="false">
    <banDurationMinutes>1440</banDurationMinutes>
    <maxFloodingAttempts>5</maxFloodingAttempts>
    <secondsBeforeBan>5</secondsBeforeBan>
    <banMode>NAME</banMode>
    <logFloodingAttempts>true</logFloodingAttempts>
    <banMessage>Too much flooding, you are banned</banMessage>
  </floodFilter>
  <rooms>
    <room>
      <name>The Lobby</name>
      <groupId>default</groupId>
      <password></password>
      <maxUsers>150</maxUsers>
      <maxSpectators>0</maxSpectators>
      <isDynamic>false</isDynamic>
      <isGame>false</isGame>
      <isHidden>false</isHidden>
      <autoRemoveMode>DEFAULT</autoRemoveMode>
      <permissions>
        <flags>PUBLIC_MESSAGES</flags>
        <maxRoomVariablesAllowed>10</maxRoomVariablesAllowed>
      </permissions>
      <events>USER_ENTER_EVENT,USER_EXIT_EVENT,USER_COUNT_CHANGE_EVENT,USER_VARIABLES_UPDATE_EVENT</events>
      <badWordsFilter isActive="false"/>
      <roomVariables/>
      <extension>
        <name></name>
      <type></type>
      <file></file>
      <propertiesFile></propertiesFile>
      <reloadMode>AUTO</reloadMode>
      </extension>
    </room>
  </rooms>
  <disabledSystemEvents/>
  <privilegeManager active="false">
    <profiles>
      <profile id="0">
        <name>Guest</name>
        <deniedRequests/>
        <permissionFlags>
          <string>ExtensionCalls</string>
        </permissionFlags>
      </profile>
      <profile id="1">
        <name>Standard</name>
        <deniedRequests/>
        <permissionFlags>
          <string>ExtensionCalls</string>
        </permissionFlags>
      </profile>
      <profile id="2">
        <name>Moderator</name>
        <deniedRequests/>
        <permissionFlags>
          <string>ExtensionCalls</string>
          <string>SuperUser</string>
        </permissionFlags>
      </profile>
      <profile id="3">
        <name>Administrator</name>
        <deniedRequests/>
        <permissionFlags>
          <string>ExtensionCalls</string>
          <string>SuperUser</string>
        </permissionFlags>
      </profile>
    </profiles>
  </privilegeManager>
  <extension>
    <name>MyGame</name>
    <type>JAVA</type>
    <file>sfs.extensions.UnoGameLobby</file>
    <propertiesFile></propertiesFile>
    <reloadMode>AUTO</reloadMode>
  </extension>
  <buddyList active="true">
    <allowOfflineBuddyVariables>true</allowOfflineBuddyVariables>
    <maxItemsPerList>100</maxItemsPerList>
    <maxBuddyVariables>15</maxBuddyVariables>
    <offlineBuddyVariablesCacheSize>500</offlineBuddyVariablesCacheSize>
    <customStorageClass></customStorageClass>
    <useTempBuddies>true</useTempBuddies>
    <buddyStates>
      <string>Available</string>
      <string>Away</string>
      <string>Occupied</string>
    </buddyStates>
    <badWordsFilter isActive="true"/>
  </buddyList>
  <databaseManager active="false">
    <driverName></driverName>
    <connectionString></connectionString>
    <userName></userName>
    <password></password>
    <testSql></testSql>
    <maxActiveConnections>10</maxActiveConnections>
    <maxIdleConnections>10</maxIdleConnections>
    <exhaustedPoolAction>FAIL</exhaustedPoolAction>
    <blockTime>3000</blockTime>
  </databaseManager>
</zone>
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Not getting login request on LoginHandler

Postby Lapo » 23 May 2020, 16:13

Hi,
you should turn the DEBUG in the client side and show us the complete transcript.
Just set the --> ConfigData.setDebug(true)

Then post here the transcript.

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
sitnik
Posts: 19
Joined: 24 Jan 2018, 08:49

Re: Not getting login request on LoginHandler

Postby sitnik » 24 May 2020, 14:35

Hi Lapo,

Actually its was already on, dont know why i removed it while providing you the client logs :)

Code: Select all

Initialised base bot
Add sfs base bot listeners
log4j:WARN No appenders could be found for logger (game).
log4j:WARN Please initialize the log4j system properly.
connecting sfs
684 [New I/O client worker #1-1] INFO sfs2x.client.core.SFSIOHandler - Data written: Binary size: 54
12 00 03 00 01 70 12 00 03 00 03 62 69 6E 01 01    .....p.....bin..
00 02 63 6C 08 00 07 41 6E 64 72 6F 69 64 00 03    ..cl...Android..
61 70 69 08 00 05 31 2E 37 2E 36 00 01 61 03 00    api...1.7.6..a..
00 00 01 63 02 00                                  ...c..         

720 [New I/O client worker #1-1] INFO sfs2x.client.core.SFSIOHandler - Data Read: Binary size: 80
80 00 4D 12 00 03 00 01 70 12 00 03 00 02 63 74    ..M.....p.....ct
04 00 00 04 00 00 02 6D 73 04 00 07 A1 20 00 02    .......ms.......
74 6B 08 00 20 32 30 34 31 63 34 66 61 30 34 61    tk...2041c4fa04a
30 31 32 39 30 66 35 63 33 30 34 38 38 37 66 64    01290f5c304887fd
34 33 37 36 65 00 01 61 03 00 00 00 01 63 02 00    4376e..a.....c..

720 [New I/O client worker #1-1] INFO sfs2x.client.core.SFSIOHandler - Handling New Packet of size 80
721 [New I/O client worker #1-1] INFO sfs2x.client.core.SFSIOHandler - Handling Data: 77, previous state: 0/77
721 [New I/O client worker #1-1] INFO sfs2x.client.core.SFSIOHandler - <<< Packet Complete >>>
connection success
726 [New I/O client worker #1-1] INFO sfs2x.client.core.SFSIOHandler - Data written: Binary size: 44
12 00 03 00 01 70 12 00 03 00 02 7A 6E 08 00 03    .....p.....zn...
55 6E 6F 00 02 70 77 08 00 00 00 02 75 6E 08 00    Uno..pw.....un..
00 00 01 61 03 00 01 00 01 63 02 00                ...a.....c..   

login sfs



I hope this helps !
just for the info, i have kept encryption off on both server and client side , as i am running the game locally on my machine.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Not getting login request on LoginHandler

Postby Lapo » 24 May 2020, 17:51

The client is working correctly.
The server side Zone seems also configured correctly, since the customLogin option is turned on.
I am not sure why you're having any issues at all.

The only thing that comes to mind is that the source code you have posted doesn't match the compiled jar.
(i.e. you made changes to the sources but did not redeploy the jar file)

Another possibility is that you have inadvertently packed the compilation dependencies inside the Extension's jar. They are only needed for compilation but they don't need to be included in the final jar file.

Hope it helps.
Lapo

--

gotoAndPlay()

...addicted to flash games
sitnik
Posts: 19
Joined: 24 Jan 2018, 08:49

Re: Not getting login request on LoginHandler

Postby sitnik » 25 May 2020, 15:19

The only thing that comes to mind is that the source code you have posted doesn't match the compiled jar.
(i.e. you made changes to the sources but did not redeploy the jar file)

If you are talking about updated code deployment then i am pretty sure that it's updated on jar as well. As i am stuck on this from many weeks, and have tried many work arounds.

Another possibility is that you have inadvertently packed the compilation dependencies inside the Extension's jar. They are only needed for compilation but they don't need to be included in the final jar file.

Can you explain a little bit more on this, i could not understand, dependencies in extension jars.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Not getting login request on LoginHandler

Postby Lapo » 25 May 2020, 15:23

Can you explain a little bit more on this, i could not understand, dependencies in extension jars.

Sure.
What I mean is that the exported jar file should not contain the SFS2X dependencies used for compilation. In other words it should only contain your classes. This is because those SFS2X jars you use for compilation in your IDE, already exist in the SFS2X folders and therefore they could cause unexpected duplications/conflicts.

Makes sense?
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 53 guests