Websockets maximum utfString size

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

croftie
Posts: 49
Joined: 24 Jul 2013, 08:35
Location: Algarve Portugal
Contact:

Websockets maximum utfString size

Postby croftie » 06 Jul 2018, 03:42

I am getting a server side error when sending large text string in utfString (binary) from javascript client using websockets. The server is Version 2.13.0

Code: Select all

Exception: java.lang.IllegalStateException
Message: Invalid SFSObject key length. Found = 25943
Description: Serialization error in incoming websocket packet.
From: { Id: 14, Type: WEBSOCKET, Logged: Yes, IP: 90.255.234.203:49245 }
+--- --- ---+
Stack Trace:
+--- --- ---+
com.smartfoxserver.v2.protocol.serialization.DefaultSFSDataSerializer.decodeSFSObject(DefaultSFSDataSerializer.java:205)
com.smartfoxserver.v2.protocol.serialization.DefaultSFSDataSerializer.decodeObject(DefaultSFSDataSerializer.java:743)
com.smartfoxserver.v2.protocol.serialization.DefaultSFSDataSerializer.decodeSFSObject(DefaultSFSDataSerializer.java:212)
com.smartfoxserver.v2.protocol.serialization.DefaultSFSDataSerializer.decodeObject(DefaultSFSDataSerializer.java:743)
com.smartfoxserver.v2.protocol.serialization.DefaultSFSDataSerializer.decodeSFSObject(DefaultSFSDataSerializer.java:212)
com.smartfoxserver.v2.protocol.serialization.DefaultSFSDataSerializer.binary2object(DefaultSFSDataSerializer.java:170)
com.smartfoxserver.v2.entities.data.SFSObject.newFromBinaryData(SFSObject.java:149)
com.smartfoxserver.bitswarm.websocket.jetty.WebSocketBinaryProtocolCodec.onPacketRead(WebSocketBinaryProtocolCodec.java:58)
sfs2x.websocket.SFS2XWSService$WSIOExecutor.run(SFS2XWSService.java:102)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


seems to be a size issue. Is there a way to increase the maximum packet size/ utfString maximum size
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Websockets maximum utfString size

Postby Lapo » 06 Jul 2018, 07:33

Hi,
the key of an SFSObject is limited to 255 characters.
In other words:

Code: Select all

sfsObj.putUtfString("name", "value");

The "name" string must be < 255 characters. This is valid for all putSomething() methods: e.g. putInt(), putUtfString() etc.
I'd highly recommend to keep it very short, e.g. 10 characters or less. Try to be as concise as possible so that you waste as little bandwidth as possible.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Baidu [Spider] and 64 guests