[SOLVED] SpiderMonkey crash on first message from server

You have to wait until you are actually connected before you can send a message. The client and the server exchange some data during connection setup.

Don’t send a message until you have the connection event.

Did you look at the chat client and server examples already?

looks like I missed this

        try {
            Thread.sleep(1000); // wait a couple beats to let the messages go out
        } catch( InterruptedException e ) {
            e.printStackTrace();
        }

let me try again when my internet not trouble

But 1 second may not be long enough.

Best to not start doing your networking until you get notified.

Put your app/networking logic into an app state that gets attached once your ClientStateListener receives the event that says things are fully connected.

Else you will just get random bugs later.

Here is a fully working networking example with everything but “the game” included:

Edit: or the JME chat example already mentioned:

…though it does nothing special with its ClientStateListener, it could have waited to enable the UI until it got clientConnected.

Iirc, all messages should register themselves after the connection is established.

If you would like to look at a more robust networking solution for jme, I wrote a library that uses netty.io.

See the wiki in the github repo for documentation on how to use it. There is also an example server and client in the repo as a good reference.

Arguable.

That is correct. They only need to be registered on the server.

…which is one of a dozen reasons that you can’t just start blasting messages until the connection is fully connected.

[Solved] at least by far. thanks.

Started client:com.jme3.network.base.DefaultClient@7e2d773b
Dec 07, 2021 8:47:32 AM com.jme3.network.message.SerializerRegistrationsMessage registerAll
INFO: Registering:Registration[-19 = com.jme3.math.Vector3f, serializer=com.jme3.network.serializing.serializers.Vector3Serializer]
Dec 07, 2021 8:47:32 AM com.jme3.network.message.SerializerRegistrationsMessage registerAll
INFO: Registering:Registration[-41 = com.jme3.network.serializing.serializers.FieldSerializer, serializer=null]
Dec 07, 2021 8:47:32 AM com.jme3.network.message.SerializerRegistrationsMessage registerAll
INFO: Registering:Registration[-43 = [I, serializer=com.jme3.network.serializing.serializers.ArraySerializer]
Dec 07, 2021 8:47:32 AM com.jme3.network.message.SerializerRegistrationsMessage registerAll
INFO: Registering:Registration[-46 = [Lcom.jme3.network.message.SerializerRegistrationsMessage$Registration;, serializer=com.jme3.network.serializing.serializers.ArraySerializer]
Dec 07, 2021 8:47:32 AM com.jme3.network.message.SerializerRegistrationsMessage registerAll
INFO: Registering:Registration[-48 = mygame.HelloMessage, serializer=null]
clientConnected(com.jme3.network.base.DefaultClient@7e2d773b)
Sending:mygame.HelloMessage@2173f6d9
Client #11 received: 'Hello World!'