Page 1 of 3
Problem when sending byte array
Posted: 10 Aug 2010, 12:21
by Alex
Hi
I'm having trouble sending byte arrays from the server to the client. Sometimes the client throws an exception:
Code: Select all
Error: DumpFormatter: the indentPos is not == 0. TOKENS ARE NOT BALANCED!
at com.smartfoxserver.v2.protocol.serialization::DefaultObjectDumpFormatter$/prettyPrintDump()[/Users/Lapo/Documents/Flex Builder 3/SFS2X_AS3_API/src/com/smartfoxserver/v2/protocol/serialization/DefaultObjectDumpFormatter.as:58]
at com.smartfoxserver.v2.entities.data::SFSObject/getDump()[/Users/Lapo/Documents/Flex Builder 3/SFS2X_AS3_API/src/com/smartfoxserver/v2/entities/data/SFSObject.as:112]
at com.smartfoxserver.v2.bitswarm::Message/toString()[/Users/Lapo/Documents/Flex Builder 3/SFS2X_AS3_API/src/com/smartfoxserver/v2/bitswarm/Message.as:58]
at Array$/_join()
at Array/http://adobe.com/AS3/2006/builtin::join()
at com.smartfoxserver.v2.logging::Logger/info()[/Users/Lapo/Documents/Flex Builder 3/SFS2X_AS3_API/src/com/smartfoxserver/v2/logging/Logger.as:80]
at com.smartfoxserver.v2.controllers::ExtensionController/handleMessage()[/Users/Lapo/Documents/Flex Builder 3/SFS2X_AS3_API/src/com/smartfoxserver/v2/controllers/ExtensionController.as:29]
at com.smartfoxserver.v2.core::SFSProtocolCodec/dispatchRequest()[/Users/Lapo/Documents/Flex Builder 3/SFS2X_AS3_API/src/com/smartfoxserver/v2/core/SFSProtocolCodec.as:97]
at com.smartfoxserver.v2.core::SFSProtocolCodec/onPacketRead()[/Users/Lapo/Documents/Flex Builder 3/SFS2X_AS3_API/src/com/smartfoxserver/v2/core/SFSProtocolCodec.as:39]
at com.smartfoxserver.v2.core::SFSIOHandler/handlePacketData()[/Users/Lapo/Documents/Flex Builder 3/SFS2X_AS3_API/src/com/smartfoxserver/v2/core/SFSIOHandler.as:229]
at com.smartfoxserver.v2.core::SFSIOHandler/onDataRead()[/Users/Lapo/Documents/Flex Builder 3/SFS2X_AS3_API/src/com/smartfoxserver/v2/core/SFSIOHandler.as:88]
at com.smartfoxserver.v2.bitswarm::BitSwarmClient/onSocketData()[/Users/Lapo/Documents/Flex Builder 3/SFS2X_AS3_API/src/com/smartfoxserver/v2/bitswarm/BitSwarmClient.as:319]
Here is a sample byte array that always throws the exception:
Code: Select all
ISFSObject testObject = new SFSObject();
byte[] tb = new byte[] { 73, -56, 0, -97, -87, -67, -68, -124, 30, -41, 84, 21, -39,
114, -107, -99, -85, 53, -100, -56, 17, -56, -16, 112, 67, -12, 75, 119, -41,
119, -52, 48, -19, 29, 2, -75, -12, -55, 70, -14, -37, -82, 77, 93, -122, 47,
-81, -114, -84, -32, 79, -50, -126, 92, -83, -6, -101, 0, -66, -125, -127, -96,
-109, 62, 114, -27, 15, -55, 84, 82, 27, 25, -69, 32, 48, -51, 21, 22, 115, 88,
100, 111, -72, 53, -97, 30, 32, -23, 123, -25, 87, -71, -105, -5, 87, 70, 121, 100,
113, 50, -107, -43, 32, -121, 95, -12, -52, -13, -26, 51, -43, -24, -128, -25,
77, 53, -78, 28, 3, -118, 61, -73, 112, -28, 35, 117, -89, 17, -107, -77, -122,
-88, -92, -93, 59, 48, -35, 4, 21, -128, -107, 87, 64, -97, 110, -111, -30, 46,
-6, -71, -127, -13, 78, -42, 12, 30, -69, 53, -120, 65, -43, 71, -32, -118, 52,
35, -108, -21, -88, -15, 87, -55, 31, -18, -15, 94, 110, 93, 60, -104, 1, -83,
17, -97, 93, 6, 70, 101, 110, -45, 50, 119, 78, 33, 8, -39, 109, -128, 52, 94,
-38, 17, 111, -31, -64, -108, -80, 57, -47, 121, 28, -35, -94, -104, 10, -13 };
testObject.putByteArray( "m", tb );
ce.getApi().sendExtensionResponse( CommonCommandNames.SYSTEM_MOVE_SEND, testObject, user, room, false );
Posted: 11 Aug 2010, 05:24
by Lapo
Thanks I will investigate.
Small suggestion... instead of callin:
Code: Select all
getApi().sendExtensionResponse(....
you have convenient
send(...) method inside your extension or event/request handler.
Essentially it's the same thing but nicer
Posted: 11 Aug 2010, 05:46
by Alex
10x I'll give it a try.
Posted: 12 Aug 2010, 05:57
by Lapo
Yep there is indeed a bug with the object dump of byte arrays. Quite a stupid one
You can download the latest API which provides a fix.
API version 0.9.0
Posted: 12 Aug 2010, 06:20
by Alex
Hi
10x for the quick fix
- It is working now.
Posted: 16 Dec 2010, 07:51
by FALinc
Hello,
I'm trying to send a byte array from my Java server extension, but there are some problems on the client iPhone side exactly like described above.
Could you please help?
I think this problem was fixed only for the AS3 and Unity clients (in RC1a update) but not for iPhone.
Posted: 16 Dec 2010, 08:01
by Lapo
I don't know if the problem is exactly the same, maybe.
So you are getting the same error message of the Actionscript version?
Posted: 16 Dec 2010, 08:15
by FALinc
Ok, when I'm trying to send a byte array from server Java extension, I'm getting this crash on the client iPhone side:
Code: Select all
*** Terminating app due to uncaught exception 'SFSCodecException', reason: 'Invalid SFSDataType. Expected: 18, found: 120'
*** Call stack at first throw:
(
0 CoreFoundation 0x0175bbe9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x018b05c2 objc_exception_throw + 47
2 MyClient 0x0009a4d4 -[DefaultSFSDataSerializer decodeSFSObject:] + 202
3 MyClient 0x0009c34b -[DefaultSFSDataSerializer binary2object:] + 222
4 MyClient 0x000b0b5b +[SFSObject newFromBinaryData:] + 72
5 MyClient 0x000b2f06 -[SFSProtocolCodec onPacketRead:] + 50
6 MyClient 0x000af611 -[SFSIOHandler handlePacketData:] + 781
7 MyClient 0x000b03a5 -[SFSIOHandler onDataRead:] + 558
8 MyClient 0x00092967 -[BitSwarmClient stream:handleEvent:] + 1753
9 CoreFoundation 0x017371d2 _inputStreamCallbackFunc + 82
10 CoreFoundation 0x0170b093 _signalEventSync + 99
11 CoreFoundation 0x0170b96e _cfstream_solo_signalEventSync + 126
12 CoreFoundation 0x0170ae09 _CFStreamSignalEvent + 457
13 CoreFoundation 0x0170b8b7 CFReadStreamSignalEvent + 39
14 CFNetwork 0x01544c37 _ZN12SocketStream40dispatchSignalFromSocketCallbackUnlockedEP24SocketStreamSignalHolder + 45
15 CFNetwork 0x0149f541 _ZN12SocketStream14socketCallbackEP10__CFSocketmPK8__CFDataPKv + 221
16 CFNetwork 0x0149f445 _ZN12SocketStream22_SocketCallBack_streamEP10__CFSocketmPK8__CFDataPKvPv + 117
17 CoreFoundation 0x016d5e40 __CFSocketDoCallback + 608
18 CoreFoundation 0x016d58ca __CFSocketPerformV0 + 138
19 CoreFoundation 0x0173d01f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
20 CoreFoundation 0x0169b28b __CFRunLoopDoSources0 + 571
21 CoreFoundation 0x0169a786 __CFRunLoopRun + 470
22 CoreFoundation 0x0169a240 CFRunLoopRunSpecific + 208
23 CoreFoundation 0x0169a161 CFRunLoopRunInMode + 97
24 GraphicsServices 0x02a1a268 GSEventRunModal + 217
25 GraphicsServices 0x02a1a32d GSEventRun + 115
26 UIKit 0x00a3442e UIApplicationMain + 1160
27 MyClient 0x000021c0 main + 82
28 MyClient 0x00002165 start + 53
The byte array is a ASCII text like this:
Code: Select all
0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#0|-1|0|-1#
The code on Java:
Code: Select all
public void createGameWithMap(User user, int w, int h, String map)
{
SFSObject response = new SFSObject();
response.putInt("w", w);
response.putInt("h", h);
response.putLong("t", System.currentTimeMillis());
response.putByteArray("m", map.getBytes());
send("createGameWithMap", response, user);
}
Posted: 16 Dec 2010, 09:33
by Lapo
Thanks, we are about to release an update. We'll do our best to check it before publishing it.
Posted: 20 Dec 2010, 15:49
by Lapo
Upon closer inspection it looks like the problem is not related with the issue originally posted. Does it happen with specific byte arrays or just any byte array?
Thank you
Posted: 22 Dec 2010, 15:32
by FALinc
Ok, I think the problem is in the packet size which exceeds "Protocol compression threshold" (1024 bytes by default).
I can see these lines in the iPhone client:
Code: Select all
-(NSData *)handlePacketData:(NSData *)data {
...
if (_pendingPacket.header.compressed) {
// TODO handle compression...
}
...
}
When I'm sending bytes array with length > 1024 bytes it's crashes with callstack I posted above.
Posted: 22 Dec 2010, 16:32
by Lapo
We'll be taking a look as soon as possible.
any updates?
Posted: 20 Jan 2011, 14:33
by MyMichellle
Hi I am having the same issue with the size of packets being sent to an iphone client. Is there any update on fixing this?
Code: Select all
2011-01-20 10:40:16.052 myProject[701:207] *** Terminating app due to uncaught exception 'SFSCodecException', reason: 'Invalid SFSDataType. Expected: 18, found: 120'
*** Call stack at first throw:
(
0 CoreFoundation 0x01b44be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x01c995c2 objc_exception_throw + 47
2 myProject 0x00119943 -[DefaultSFSDataSerializer decodeSFSObject:] + 202
3 myProject 0x0011b7ba -[DefaultSFSDataSerializer binary2object:] + 222
4 myProject 0x0012ffbe +[SFSObject newFromBinaryData:] + 72
5 myProject 0x00132369 -[SFSProtocolCodec onPacketRead:] + 50
6 myProject 0x0012ea83 -[SFSIOHandler handlePacketData:] + 781
7 myProject 0x0012f7f7 -[SFSIOHandler onDataRead:] + 558
8 myProject 0x00111e1b -[BitSwarmClient stream:handleEvent:] + 1753
9 CoreFoundation 0x01b201d2 _inputStreamCallbackFunc + 82
10 CoreFoundation 0x01af4093 _signalEventSync + 99
11 CoreFoundation 0x01af496e _cfstream_solo_signalEventSync + 126
12 CoreFoundation 0x01af3e09 _CFStreamSignalEvent + 457
13 CoreFoundation 0x01af48b7 CFReadStreamSignalEvent + 39
14 CFNetwork 0x015c2c37 _ZN12SocketStream40dispatchSignalFromSocketCallbackUnlockedEP24SocketStreamSignalHolder + 45
15 CFNetwork 0x0151d541 _ZN12SocketStream14socketCallbackEP10__CFSocketmPK8__CFDataPKv + 221
16 CFNetwork 0x0151d445 _ZN12SocketStream22_SocketCallBack_streamEP10__CFSocketmPK8__CFDataPKvPv + 117
17 CoreFoundation 0x01abee40 __CFSocketDoCallback + 608
18 CoreFoundation 0x01abe8ca __CFSocketPerformV0 + 138
19 CoreFoundation 0x01b2601f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
20 CoreFoundation 0x01a8428b __CFRunLoopDoSources0 + 571
21 CoreFoundation 0x01a83786 __CFRunLoopRun + 470
22 CoreFoundation 0x01a83240 CFRunLoopRunSpecific + 208
23 CoreFoundation 0x01a83161 CFRunLoopRunInMode + 97
24 GraphicsServices 0x02d9a268 GSEventRunModal + 217
25 GraphicsServices 0x02d9a32d GSEventRun + 115
26 UIKit 0x00a4942e UIApplicationMain + 1160
27 myProjec[Switching to process 701]
m 0x00002390 main + 82
28 myProject 0x00002335 start + 53
Posted: 21 Jan 2011, 12:42
by Lapo
Yes we do have an update.
You can download it from here.
Pleas let us know if it works for you.
Posted: 24 Jan 2011, 14:46
by MyMichellle
I am still having the issue after downloading and using the update.
For example if I send a string, or multiple strings, that are too long I get the crash on the ios side.
Here is the server side code sending an example string that is 1514 chars long.
Code: Select all
package myZone;
import java.util.LinkedList;
import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.smartfoxserver.v2.entities.data.SFSObject;
public class JoinGameReqHandler extends BaseClientRequestHandler
{
@Override
public void handleClientRequest(User sender, ISFSObject params)
{
LinkedList<User> receiverList = new LinkedList<User>();
receiverList.add(sender);
ISFSObject response = new SFSObject();
response.putUtfString("test", "This is a free typing test that tests your typing speed. Typing speed is defined in wpm, which is words typed per minute. A word is taken to be five characters long including blank spaces. Typing speed is also defined as strokes typed per minute. This typing speed test will tell you your typing speed in wpm, words per minute, as soon as you finish typing this short paragraph. This is a free typing test that tests your typing speed. Typing speed is defined in wpm, which is words typed per minute. A word is taken to be five characters long including blank spaces. Typing speed is also defined as strokes typed per minute. This typing speed test will tell you your typing speed in wpm, words per minute, as soon as you finish typing this short paragraph.This is a free typing test that tests your typing speed. Typing speed is defined in wpm, which is words typed per minute. A word is taken to be five characters long including blank spaces. Typing speed is also defined as strokes typed per minute. This typing speed test will tell you your typing speed in wpm, words per minute, as soon as you finish typing this short paragraph. This is a free typing test that tests your typing speed. Typing speed is defined in wpm, which is words typed per minute. A word is taken to be five characters long including blank spaces. Typing speed is also defined as strokes typed per minute. This typing speed test will tell you your typing speed in wpm, words per minute, as soon as you finish typing this short paragraph.");
send("joinGame", response, receiverList);
}
}
This is the crash on the ios side when trying to receive the packet containing the test string.
Code: Select all
2011-01-24 11:10:13.437 myProject[5375:207] *** Terminating app due to uncaught exception 'SFSCodecException', reason: 'Invalid SFSDataType. Expected: 18, found: 120'
*** Call stack at first throw:
(
0 CoreFoundation 0x01b45be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x01c9a5c2 objc_exception_throw + 47
2 myProject 0x0012098a -[DefaultSFSDataSerializer decodeSFSObject:] + 202
3 myProject 0x00122801 -[DefaultSFSDataSerializer binary2object:] + 222
4 myProject 0x00137005 +[SFSObject newFromBinaryData:] + 72
5 myProject 0x001393b0 -[SFSProtocolCodec onPacketRead:] + 50
6 myProject 0x00135aca -[SFSIOHandler handlePacketData:] + 781
7 myProject 0x0013683e -[SFSIOHandler onDataRead:] + 558
8 myProject 0x00118e40 -[BitSwarmClient stream:handleEvent:] + 1758
9 CoreFoundation 0x01b211d2 _inputStreamCallbackFunc + 82
10 CoreFoundation 0x01af5093 _signalEventSync + 99
11 CoreFoundation 0x01af596e _cfstream_solo_signalEventSync + 126
12 CoreFoundation 0x01af4e09 _CFStreamSignalEvent + 457
13 CoreFoundation 0x01af58b7 CFReadStreamSignalEvent + 39
14 CFNetwork 0x015c3c37 _ZN12SocketStream40dispatchSignalFromSocketCallbackUnlockedEP24SocketStreamSignalHolder + 45
15 CFNetwork 0x0151e541 _ZN12SocketStream14socketCallbackEP10__CFSocketmPK8__CFDataPKv + 221
16 CFNetwork 0x0151e445 _ZN12SocketStream22_SocketCallBack_streamEP10__CFSocketmPK8__CFDataPKvPv + 117
17 CoreFoundation 0x01abfe40 __CFSocketDoCallback + 608
18 CoreFoundation 0x01abf8ca __CFSocketPerformV0 + 138
19 CoreFoundation 0x01b2701f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
20 CoreFoundation 0x01a8528b __CFRunLoopDoSources0 + 571
21 CoreFoundation 0x01a84786 __CFRunLoopRun + 470
22 CoreFoundation 0x01a84240 CFRunLoopRunSpecific + 208
23 CoreFoundation 0x01a84161 CFRunLoopRunInMode + 97
24 GraphicsServices 0x02d9b268 GSEventRunModal + 217
25 GraphicsServices 0x02d9b32d GSEventRun + 115
26 UIKit 0x00a4a42e UIApplicationMain + 1160
27 myProject 0x000029f0 main + 82
28 myProject 0x00002995 start + 53
)
terminate called after throwing an instance of 'SFSCodecException'