Receiving Unexpected null or empty byte array!

Post here your questions about the Java client / Android API for SFS2X

Moderators: Lapo, Bax

efsnet
Posts: 55
Joined: 14 Nov 2013, 20:48

Receiving Unexpected null or empty byte array!

Postby efsnet » 20 Nov 2013, 18:13

Hello,

When attempting to send some data to the server, the server responds with "Unexpected null or empty byte array!"

Here's the full stack trace:

Code: Select all

11:06:53,971 ERROR [1634888284@qtp-480934059-7] mortbay.log     - /BlueBox/BlueBox.do
java.lang.IllegalArgumentException: Unexpected null or empty byte array!
   at com.smartfoxserver.v2.protocol.SFSIoHandler.onDataRead(SFSIoHandler.java:80)
   at com.smartfoxserver.v2.bluebox.BlueBox.doPost(BlueBox.java:144)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
   at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
   at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1221)
   at com.smartfoxserver.v2.bluebox.SessionFilter.doFilter(SessionFilter.java:141)
   at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
   at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
   at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
   at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
   at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
   at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
   at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
   at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
   at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
   at org.mortbay.jetty.Server.handle(Server.java:326)
   at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
   at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
   at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
   at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
   at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
   at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
   at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)



The java code that causes this error is:

Code: Select all

   SFSObject obj = new SFSObject();
      
      obj.putInt("mh", 5);
      obj.putInt("mw", 5);
      obj.putInt("mt", 5);
      obj.putInt("ms", 5);
      obj.putInt("mi', 5);
      
      SFSArray otherArray = new SFSArray();
      
      for(int j = 0; j< 5; j++) {
      
         SFSArray array = new SFSArray();
         
         for(int i = 0; i < 5; i++) {
            SFSObject tileObject = new SFSObject();

            tileObject.putInt("ix", i);
            tileObject.putInt("iy", j);
            tileObject.putInt("bt", 1);
            tileObject.putInt("mt", 2);
            tileObject.putInt("ft", 3);
            
            array.addSFSObject(tileObject);
         }
         otherArray.addSFSArray(array);
      }
      obj.putSFSArray("ts",otherArray);
      
      sfsClient.send(new ExtensionRequest(Commands.SEND_SERVER_MAP, obj, sfsClient.getLastJoinedRoom()));


Oddly, if the following two lines are deleted, the server doesn't throw the exception:

Code: Select all

            tileObject.putInt("mt", 2);
            tileObject.putInt("ft", 3);


The connection is blue box enabled. Could this problem be associated with the C# issue previously reported?

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

Re: Receiving Unexpected null or empty byte array!

Postby Lapo » 20 Nov 2013, 19:57

Hi,
it could be related, I suspect it could be an encoding issues. We'll investigate.
Meanwhile can you please report what version of the Java API are you using? (see the SmartFox.getVersion() method)

Also what is the value of the Commands.SEND_SERVER_MAP string? We need that as well to replicate the case.

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
efsnet
Posts: 55
Joined: 14 Nov 2013, 20:48

Re: Receiving Unexpected null or empty byte array!

Postby efsnet » 20 Nov 2013, 20:26

Java API 1.2.0

SEND_SERVER_MAP == sms

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

Re: Receiving Unexpected null or empty byte array!

Postby Lapo » 21 Nov 2013, 09:49

Thanks.
We reproduced the problem and found the cause, similar to C#.

If you need a quick fix we can send a pre-release package. At the moment we're working on supporting the new features of SFS2X 2.8 in the Java API so the new official update might take a while before it's released (if all goes 2-3 weeks).

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
efsnet
Posts: 55
Joined: 14 Nov 2013, 20:48

Re: Receiving Unexpected null or empty byte array!

Postby efsnet » 21 Nov 2013, 21:34

Thanks for looking into this, I'll be eagerly awaiting the update.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Receiving Unexpected null or empty byte array!

Postby Lapo » 25 Nov 2013, 12:26

We have released a new API update that addresses the problem you have reported and provides support for the new MMO API introduce in SFS2X 2.8.0
See here:
viewtopic.php?f=22&t=16645

cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
efsnet
Posts: 55
Joined: 14 Nov 2013, 20:48

Re: Receiving Unexpected null or empty byte array!

Postby efsnet » 25 Nov 2013, 23:18

Thanks Lapo!

Return to “SFS2X Java / Android API”

Who is online

Users browsing this forum: No registered users and 20 guests