Can't send certain floats.

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

Birch
Posts: 15
Joined: 06 Jun 2012, 07:42
Location: Sweden

Can't send certain floats.

Postby Birch » 12 Jul 2012, 09:42

Hello!

I've got a really strange problem, i am trying to do a really simple thing, put a float in a SFSObject and sending it to the server.

This code works:

Code: Select all


   void test(){
      
      SFSObject data = new SFSObject();
      
      data.PutFloat("x", 2.305684f);
      
      smartfox.Send(new ExtensionRequest("moveRequest", data, MainSmartfox.smartfox.LastJoinedRoom, false));            
      
   }         



This code doesn't work:

Code: Select all


   void test(){
      
      SFSObject data = new SFSObject();
      
      data.PutFloat("x", 1.305684f);
      
      smartfox.Send(new ExtensionRequest("moveRequest", data, smartfox.LastJoinedRoom, false));            
      
   }



The only thing i changed was that i increased the float with 1, and suddenly it works! I am have absolutely no clue whats going on and all help is appreciated!

These floats doesn't work either:
1.305684
-1.448122
1.258205
2.796537

The error message in the smartfox console:

Code: Select all


11:24:12,688 ERROR [1939520811@qtp-182510869-5] 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:138)
   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)

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

Re: Can't send certain floats.

Postby Lapo » 13 Jul 2012, 11:23

Hi,
1) Which Server version are you using?
2) Does the problem happen without using the BlueBox connetion? Maybe there's a relation.

thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
Birch
Posts: 15
Joined: 06 Jun 2012, 07:42
Location: Sweden

Re: Can't send certain floats.

Postby Birch » 13 Jul 2012, 11:52

I am using SFS2X 2.0.1, and setting useBluebox to false doesn't change anything.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Can't send certain floats.

Postby Lapo » 13 Jul 2012, 12:05

Please do me a favour. Install the latest patch (it won't require a new full installation) then run your test again and without connecting to the BlueBox. I need this in order to see where the problem is with a direct connection.
Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Can't send certain floats.

Postby Lapo » 13 Jul 2012, 12:11

Btw, as a workaround, have you tried using a double instead? Does it work?
Lapo

--

gotoAndPlay()

...addicted to flash games
Birch
Posts: 15
Joined: 06 Jun 2012, 07:42
Location: Sweden

Re: Can't send certain floats.

Postby Birch » 13 Jul 2012, 12:22

Same problem with Double as with Float :?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Can't send certain floats.

Postby Lapo » 13 Jul 2012, 13:51

Can you try what I have suggested and post the result here? Also there's a new release of the C# API. We need to make sure that the problem is present in the current version.
Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
Birch
Posts: 15
Joined: 06 Jun 2012, 07:42
Location: Sweden

Re: Can't send certain floats.

Postby Birch » 14 Jul 2012, 09:55

I downloaded the latest patch and C# api and turned off bluebox, and now it works, but without bluebox i still get the same error. I've also noticed (when using bluebox) that if i convert the floats to double, i can send them. But then there're other numbers that won't work.

Can't send as float:
1.305684
-1.448122
1.258205
2.796537

Can't send as double:
-0.09495857f
0.08546299
-1.93716
1.880184
3.124145
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Can't send certain floats.

Postby Lapo » 14 Jul 2012, 14:05

I downloaded the latest patch and C# api and turned off bluebox, and now it works, but without bluebox i still get the same error.

I don't follow:
you say you turned off the BBox and it works. Then you go on saying that without Bluebox you still get the error. Which one is correct?
Lapo

--

gotoAndPlay()

...addicted to flash games
Birch
Posts: 15
Joined: 06 Jun 2012, 07:42
Location: Sweden

Re: Can't send certain floats.

Postby Birch » 14 Jul 2012, 17:30

Sorry! With bluebox i got the error.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Can't send certain floats.

Postby Lapo » 15 Jul 2012, 11:21

Thanks. I have tested using Flash and the problem is not reproducible, so I would be inclined to think that this is a C# specific issue.
I will ask Thomas Lund to look into it.

Stay tuned for an update soon.
Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Re: Can't send certain floats.

Postby ThomasLund » 19 Jul 2012, 09:41

Very weird.

I've made a small test case as well and cannot! reproduce.

Code: Select all

         ISFSObject args = new SFSObject();
         args.PutFloat("x", 1.305684f);
         
/*         1.305684
-1.448122
1.258205
2.796537
                   */
         
         sfs1.Send(new ExtensionRequest("TestCmd", args, sfs1.LastJoinedRoom));


Sends all numbers perfectly fine over bluebox. Server even returns it and I print the number. See output below.

Could you try to run your testcode with debug enabled and grab the packet dump similar to mine?

Code: Select all

SFS - DEBUG] Writing message Binary Size: 38
12 00 03 00 01 63 08 00 07 54 65 73 74 43 6d 64    .....c...TestCmd
00 01 72 04 00 00 00 02 00 01 70 12 00 01 00 01    ..r.......p.....
78 06 3f a7 20 a7                                  x.?...         

[SFS - DEBUG] [ BB-Send ]: e0060140f59ea46ac89fcea835fb2172|data|kAA3EgADAAFjAgEAAWEDAA0AAXASAAMAAWMIAAdUZXN0Q21kAAFyBAAAAAIAAXASAAEAAXgGP6cgpw==
[SFS - DEBUG] [ BB-Receive ]:
[SFS - DEBUG] [ BB-Send ]: e0060140f59ea46ac89fcea835fb2172|poll|null
[SFS - DEBUG] [ BB-Receive ]: poll|gAA8EgADAAFhAwANAAFjAgEAAXASAAMAAXIEAAAAAgABYwgADFRlc3RSZXNwb25zZQABcBIAAQABeAY/pyCngAAqEgADAAFhAwPpAAFjAgAAAXASAAMAAXIEAAAAAgACdWMDAAIAAnNjAwAA
[SFS - INFO] Data Read: Binary Size: 108
80 00 3c 12 00 03 00 01 61 03 00 0d 00 01 63 02    ..<.....a.....c.
01 00 01 70 12 00 03 00 01 72 04 00 00 00 02 00    ...p.....r......
01 63 08 00 0c 54 65 73 74 52 65 73 70 6f 6e 73    .c...TestRespons
65 00 01 70 12 00 01 00 01 78 06 3f a7 20 a7 80    e..p.....x.?....
00 2a 12 00 03 00 01 61 03 03 e9 00 01 63 02 00    .*.....a.....c..
00 01 70 12 00 03 00 01 72 04 00 00 00 02 00 02    ..p.....r.......
75 63 03 00 02 00 02 73 63 03 00 00                uc.....sc...   

[SFS - DEBUG] Handling New Packet of size 108
[SFS - DEBUG] Handling Header Size. Length: 107 (small)
[SFS - DEBUG] Data size is 60
[SFS - DEBUG] Handling Data: 105, previous state: 0/60
[SFS - DEBUG] <<< Packet Complete >>>
[SFS - INFO] { Message id: 13 }
{ Dump: }

   (int) r: 2
   (utf_string) c: TestResponse
   (sfs_object) p:
      (float) x: 1,305684
   

[SFS - DEBUG] Handling New Packet of size 45
Received: 1,305684

Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund
Birch
Posts: 15
Joined: 06 Jun 2012, 07:42
Location: Sweden

Re: Can't send certain floats.

Postby Birch » 19 Jul 2012, 14:46

And where do i find these packet dumps? :)
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Re: Can't send certain floats.

Postby ThomasLund » 10 Aug 2012, 11:58

If you set debug flag to true on your connection, they will appear in the Unity editor.log/player.log
Full Control - maker of Unity/C# and Java SFS API and indie games

Follow on twitter: http://twitter.com/thomas_h_lund

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 28 guests