Exception at spidermonkey networking

I get the following exception:
Jul 16, 2014 9:20:23 PM com.jme3.network.base.DefaultClient handleError
Schwerwiegend: Termining connection due to unhandled error
com.jme3.network.kernel.ConnectorException: Connector closed.
at com.jme3.network.base.ConnectorAdapter.run(ConnectorAdapter.java:161)

The complete code is the following:

  • To change this template, choose Tools | Templates
  • and open the template in the editor.
    package de.gamebasis.networkconnector;

import com.jme3.network.Client;
import com.jme3.network.Network;
import com.jme3.network.serializing.Serializer;
import de.gamebasis.client.GameClientStateListener;
import de.gamebasis.client.GameState;
import de.gamebasis.client.Main;
import de.gamebasis.clientlistener.ClientListener;
import de.gamebasis.event.GameStartEvent;
import de.gamebasislib.console.GameConsoleMessage;
import de.gamebasislib.event.GameEventManager;
import de.gamebasislib.gameworld.GameWorldHeightMap;
import de.gamebasislib.player.PlayerPosMessage;
import de.gamebasislib.terrain.TerrainLoadMessage;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;


  • @author Justin
    public class NetworkConnector {

    protected Client client = null;
    protected String server = “”;
    protected int port = 6143;
    protected GameClientStateListener gameclientstatelistener = null;
    protected int clientID = -1;
    protected ClientListener clientlistener = null;

    protected GameConsoleMessage gameconsolemessage = new GameConsoleMessage();
    protected static NetworkConnector instance = null;
    protected String username = “”;
    protected String password = “”;

    public NetworkConnector (Client client, GameClientStateListener gameclientstatelistener) {
    this.client = client;
    this.gameclientstatelistener = gameclientstatelistener;



    public boolean setUpNetwork (String server, int port, String username, String password) {
    try {
    this.server = server;
    this.port = port;
    this.username = username;
    this.password = password;

         //Client mit Server verbinden
         this.client = Network.connectToServer(this.server, this.port);
         //ClientStateListener hinzufügen
         this.clientlistener = new ClientListener();
         this.clientID = this.client.getId();
         Logger.getLogger(NetworkConnector.class.getName()).log(Level.INFO, "Client connected, client ID " + this.client.getId() + ".");
         //Message Klassen beim Serializer registrieren
         this.client.addMessageListener(this.clientlistener, GameWorldHeightMap.class);
         //Event werfen
         GameStartEvent gamestartevent = new GameStartEvent(client);
         //TerrainLoadMessage schicken, damit der Server dem Client eine GameWorldTerrain Message schickt
         TerrainLoadMessage terrainloadmessage = new TerrainLoadMessage();
         GameState.isConnected = true;
         return true;
     } catch (IOException ex) {
         Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
     return false;


    public String getServer () {
    return this.server;

    public int getPort () {
    return this.port;

    public int getClientID () {
    return this.clientID;

    public Client getClient () {
    return this.client;

    public GameClientStateListener getGameClientStateListener () {
    return this.gameclientstatelistener;

    public ClientListener getClientListener () {
    return this.clientlistener;

    public static NetworkConnector getInstance () {
    return NetworkConnector.instance;

    public static void setInstance (NetworkConnector networkconnector) {
    NetworkConnector.instance = networkconnector;


Why does the application throw this exception?

There was an error on the server. We can’t see it so that’s about all the help we can give.

Your client state listener on the client probably also got notified that the connection was closed… probably even with the error that caused it.

You can/should also add an ErrorListener to the client.