Weird Kryonet Serialization Error Randomly

34 views
Skip to first unread message

Brad Gilbert

unread,
Jun 4, 2017, 9:34:36 PM6/4/17
to kryonet-users
Hi Guys,

I get this error after awhile (but randomly):


It's not right when I run the application, but after connecting / reconnecting like 20 - 30 times.

Here is the listener where I think it crashes:

public class GameStateListener extends Listener {
 
 
GameStateRecvSystem gameStateSystem;
 
 
public GameStateListener(GameStateRecvSystem gameStateSystem) {
 
this.gameStateSystem = gameStateSystem;
 
}
 
 
public void received (Connection connection, Object object) {
       
if (object instanceof GameStateMsg) {
       
final GameStateMsg msg = (GameStateMsg)object;


       
Gdx.app.postRunnable(new Runnable() {
         
@Override
         
public void run() {
         gameStateSystem
.setGameState(msg.gameState);
         
}
     
});
       
}
     
}
}


I'm using Kryonet 2.21 from the Github releases page.

Joachim Durchholz

unread,
Jun 5, 2017, 4:18:37 AM6/5/17
to kryone...@googlegroups.com
I never used KryoNet in anger so I may be misinterpreting stuff, but
here's my interpretation of the error:

Am 05.06.2017 um 03:34 schrieb Brad Gilbert:
> Hi Guys,
>
> I get this error after awhile (but randomly):
>
> https://gist.github.com/anonymous/96b6b9f4c9e056290e5f2b791c95c9ac

The error is this:

--
Caused by: com.esotericsoftware.kryo.KryoException:
java.lang.ClassCastException: my.game.components.TilePositionComponent
cannot be cast to com.badlogic.gdx.math.Vector3
Serialization trace:
oldTilePosition (my.game.components.SpriteComponent)
components (my.game.networking.NetworkEntity)
networkEntities (my.game.networking.GameState)
gameState (my.game.networking.messages.GameStateMsg)
--

I.e. it is getting a my.game.components.TilePositionComponent where it
required a com.badlogic.gdx.math.Vector3.
The serialization trace looks like it is deserializing the
oldTilePosition of a SpriteComponent, expected a TilePositionComponent
but got a Vector3 instead.
The typical cause would be that client and server disagree about the
type of oldTilePosition. This wouldn't matter as long as oldTilePosition
is null, and trigger as soon as a non-null oldTilePosition is
transferred. This might explain the seemingly random behaviour.


Entirely unrelated: I see

Writing 1024x256: res\pack\game.png

in the output. In the Java world, it is strongly recommended to use / in
all pathnames unless you're talking directly to the filesystem, or to
some external software that expects a platform-formatted pathname
string. Please ask a search engine for details, this message is too long
already :-)

HTH
Jo
Reply all
Reply to author
Forward
0 new messages