java.nio.BufferUnderflowException

Hi,

i need some help.
Situation:
I have two servers and one client.
The server, which get the client connection later, connects to the second server.
All good until this. (sending messages etc.)

Now i start my client and connecting to the first server.
When the client sends the first message i got following exception:

[java]
new Connection: /127.0.0.1:58795
Jul 27, 2014 1:31:10 AM com.jme3.network.base.KernelAdapter reportError
SEVERE: Unhandled error, endpoint:NioEndpoint[1, java.nio.channels.SocketChannel[connected local=/127.0.0.1:25714 remote=/127.0.0.1:58795]], context:Envelope[NioEndpoint[1, java.nio.channels.SocketChannel[connected local=/127.0.0.1:25714 remote=/127.0.0.1:58795]], reliable, 23]
java.nio.BufferUnderflowException
at java.nio.Buffer.nextGetIndex(Unknown Source)
at java.nio.HeapByteBuffer.getChar(Unknown Source)
at com.jme3.network.serializing.serializers.CharSerializer.readObject(CharSerializer.java:47)
at com.jme3.network.serializing.serializers.CharSerializer.readObject(CharSerializer.java:43)
at com.jme3.network.serializing.serializers.ArraySerializer.readArray(ArraySerializer.java:147)
at com.jme3.network.serializing.serializers.ArraySerializer.readObject(ArraySerializer.java:88)
at com.jme3.network.serializing.serializers.FieldSerializer.readObject(FieldSerializer.java:135)
at com.jme3.network.serializing.Serializer.readClassAndObject(Serializer.java:357)
at com.jme3.network.base.MessageProtocol.createMessage(MessageProtocol.java:180)
at com.jme3.network.base.MessageProtocol.addBuffer(MessageProtocol.java:160)
at com.jme3.network.base.KernelAdapter.createAndDispatch(KernelAdapter.java:216)
at com.jme3.network.base.KernelAdapter.run(KernelAdapter.java:280)
[/java]

All needed classes are registered on both sides.

What’s wrong?

greetings
qp

I got the exception on the first server, sorry…

Well, there is more than “both sides”, right? There is all three sides: client plus two servers. Someone must be different or there is other information missing.

I also wonder what the message is… serializing a field that’s a character array seems like a bad way to send data.

Bad way or not, it doesn’t work.
I send the user login information and the passwd is a char[].

There are three sides, yes. But there is no communication between the second server and the client.

Next i changed the char[] to a string, but i just get the same error.
Now i deleted all fields in my cmd…i just get the same error :frowning:

@VqpV said: There are three sides, yes. But there is no communication between the second server and the client.

Then what is the second server for?

Who is connecting to whom and when, exactly?

There is only one serializer as it’s a singleton. So wherever you are connecting to with a particular Java process, has to share the exact same serializer configuration. If server 1 connects to server 2 then they both need the same classes registered with the serializer in the exact same order. If client connects to either of those then it also needs all the same classes registered with the serializer in the exact same order.

This is why the recommended practice is to have one class register all of your messages and then share that between client and server.

I got it to run.
I checked out the serializer and found the default id fallback.
There need to be all classes (sever2server and client2server) in the same order on all 3 sides.
I didnt realize it in the documentation.
Now i wrote a Gloabal serializer registrator.

thx for help :slight_smile: