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>