java.lang.ArrayIndexOutOfBoundsException

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

johnwayne01
Posts: 7
Joined: 09 Aug 2009, 04:04

java.lang.ArrayIndexOutOfBoundsException

Postby johnwayne01 » 09 Aug 2009, 16:54

I installed 1.6.6 pro to resolve an issue that I had on 1.6.2 pro which presented issues on it's own but I will not get into that on this thread for those issues I will leave them to the other thread.

The problem that I am having is when sending a raw str message to the server from more than 2 users at a time. I should probably point out that on the client side I use as3 and on the server I use java. I get the warning message:

10:41:00.906 - [ WARNING ] > String message in wrong format: b%nwgs%0% -> java.lang.ArrayIndexOutOfBoundsException: -1

So Initially I thought I was doing something wrong and I tried a few different things but here is the original function on the client side:

//HEADER_REQUEST_SELF_INFO = "nwgs"
public function sendNotificationWaitingGameStart():void{
var arrSend:Array = new Array();
sfs.sendXtMessage( extension , HEADER_NOTIFY_WAITING_GAME_START , arrSend , SmartFoxClient.XTMSG_TYPE_STR , 0 );
}

I tried:

sfs.sendXtMessage( extension , HEADER_NOTIFY_WAITING_GAME_START , null , SmartFoxClient.XTMSG_TYPE_STR , 0 );

Also tried:

public function sendNotificationWaitingGameStart():void{
var arrSend:Array = new Array();
arrSend.push( "a" );
arrSend.push( "b" );
arrSend.push( "c" );
arrSend.push( "d" );
sfs.sendXtMessage( extension , HEADER_NOTIFY_WAITING_GAME_START , arrSend , SmartFoxClient.XTMSG_TYPE_STR , 0 );
}

resulted in multiple:

11:19:21.468 - [ WARNING ] > String message in wrong format: b%nwgs%0%a%b%c%d% -> java.lang.ArrayIndexOutOfBoundsException: -1


I also tried other things but it is really strange because this ONLY happens when there is more than 2 users sending it at once. Meaning if there is just 1 or 2 users sending this to the server then there is no issue at all but if there is 3 or more I get this from the server:

10:41:00.906 - [ WARNING ] > String message in wrong format: b%nwgs%0% -> java.lang.ArrayIndexOutOfBoundsException: -1
10:41:00.906 - [ WARNING ] > String message in wrong format: b%nwgs%0% -> java.lang.ArrayIndexOutOfBoundsException: -1
10:41:00.906 - [ WARNING ] > String message in wrong format: b%nwgs%0% -> java.lang.ArrayIndexOutOfBoundsException: -1

Also this warning message that is shown is not from my code and if it was I would get a stack dump with the details of the error, it happens before I get:

public void handleRequest(String cmd, String[] params, User u, int fromRoom){}

I considered posting this as a bug in the bugs section but I'm not entirely sure that this is a bug because it is still possible that I'm doing something wrong. I would appreciate any input on getting this resolved.

Thanks
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 09 Aug 2009, 22:39

Hi,
try removing the last parameter (0) unless there's a specific reason to use it.
Lapo
--
gotoAndPlay()
...addicted to flash games
johnwayne01
Posts: 7
Joined: 09 Aug 2009, 04:04

Postby johnwayne01 » 11 Aug 2009, 02:13

by removing the very last parameter roomId defaults to -1 which I did try along with many other things but the only way I can prevent that warning message from coming up is to set the server config.xml logging level to a very low setting like SEVERE instead of the FINEST which I normally use.

I wonder if there is anyone else who uses the raw str method of sending messages that has this exact same problem? or am I alone on this one :?
wallis2xk
Posts: 43
Joined: 01 Sep 2006, 10:00
Location: United Kingdom

Postby wallis2xk » 16 Oct 2009, 16:19

Just in case this helps anyone else, I had this error message and it turned out it had nothing to do with what/how how I was sending it. It was because I had some bad code on my server side within the handleRequest function.

I presume SFS is catching that particular error on its side and I just happened to code something which caused that error to be thrown, but is a bit misleading :)
User avatar
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Postby BigFIsh » 16 Oct 2009, 19:48

I encountered a error similar to yours because the client wasn't in a room yet (hence the -1 for roomId)
Smartfox's forum is my daily newspaper.

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 43 guests