Error deserializing and Invalid length (3 posts)

  • Profile picture of timm3h timm3h said 6 months, 1 week ago:

    Hi I am having an issue when my client connects to my server. I have the same class on both the server and the client. Both register the classes in the same order.

    Any thoughts?

    SEVERE: Unhandled error, endpoint:NioEndpoint[1, java.nio.channels.SocketChannel[connected local=/127.0.0.1:4242 remote=/127.0.0.1:55239]], context:Envelope[NioEndpoint[1, java.nio.channels.SocketChannel[connected local=/127.0.0.1:4242 remote=/127.0.0.1:55239]], reliable, 15]
    java.lang.RuntimeException: Error deserializing object
    at com.jme3.network.base.MessageProtocol.createMessage(MessageProtocol.java:186)
    at com.jme3.network.base.MessageProtocol.addBuffer(MessageProtocol.java:162)
    at com.jme3.network.base.KernelAdapter.createAndDispatch(KernelAdapter.java:196)
    at com.jme3.network.base.KernelAdapter.run(KernelAdapter.java:260)
    Caused by: java.io.IOException: Could not read String: Invalid length identifier.
    at com.jme3.network.serializing.serializers.StringSerializer.readObject(StringSerializer.java:64)
    at com.jme3.network.serializing.serializers.StringSerializer.readObject(StringSerializer.java:45)
    at com.jme3.network.serializing.serializers.ArraySerializer.readArray(ArraySerializer.java:148)
    at com.jme3.network.serializing.serializers.ArraySerializer.readObject(ArraySerializer.java:89)
    at com.jme3.network.serializing.Serializer.readClassAndObject(Serializer.java:337)
    at com.jme3.network.base.MessageProtocol.createMessage(MessageProtocol.java:182)
    … 3 more

  • Profile picture of pspeed pspeed815p said 6 months, 1 week ago:

    Something is different on the client and the server. How are you sure that the classes are registered in the same order? Do you only register them from a single shared utility class?

    Otherwise, we will have to see the offending message class and referenced classes. Looks like it was trying to read a string that is the field of an object that is the field of another object that was in an array.

  • Profile picture of timm3h timm3h said 6 months, 1 week ago:

    Figured it out.

    I have 2 network connections, each on a different port. The problem was that I was registering the classes in both methods when they only need to be registered once.