I configured my client properly now, and I’m no longer having issues on that end. I am now experiencing an error regarding my server now. I’ve done a bit of research on this forum, and I haven’t found a solution yet, but I have tried a few things that I’ve read about. Here’s my issue:
I have tested and successfully connected both local and external (LAN and not LAN) clients to my server. The server tells them information about the world so that it can be rendered, and the client can then move about freely, as should be. The issue I’m having is an error(s) that occurs when I try to connect to the server from any computer other than the one the server is running on. The error is as follows:
Jul 24, 2012 3:09:28 AM com.jme3.network.kernel.AbstractKernel reportError
SEVERE: Unhanddled kernel error
java.io.IOException: An established connection was aborted by the software in your host machine
at sun.nio.ch.SocketDispatcher.write0(Native Method)
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:51)
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:89)
at sun.nio.ch.IOUtil.write(IOUtil.java:60)
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:450)
at com.jme3.network.kernel.tcp.SelectorKernel$SelectorThread.write(SelectorKernel.java:398)
at com.jme3.network.kernel.tcp.SelectorKernel$SelectorThread.select(SelectorKernel.java:431)
at com.jme3.network.kernel.tcp.SelectorKernel$SelectorThread.run(SelectorKernel.java:459)
Jul 24, 2012 3:10:06 AM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[Headless Application Thread,5,main]
java.lang.OutOfMemoryError: Java heap space
at java.nio.HeapByteBuffer.(HeapByteBuffer.java:57)
at java.nio.ByteBuffer.allocate(ByteBuffer.java:331)
at com.jme3.network.base.MessageProtocol.messageToBuffer(MessageProtocol.java:70)
at com.jme3.network.base.DefaultServer.broadcast(DefaultServer.java:201)
at com.jme3.network.base.DefaultServer.broadcast(DefaultServer.java:193)
at Server.MyGameServer.simpleUpdate(MyGameServer.java:200)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:241)
at com.jme3.system.NullContext.run(NullContext.java:131)
at java.lang.Thread.run(Thread.java:722)
From reading other posts, I've learned that the Java heap space error may be the program running out of memory, but I've tried increasing its memory to 512m and to 1024m, and it still appears with this error. There is nothing in my code that would take this much memory, so I suspect I have a leak.
One thing that may be the cause is my method of "player markers". Essentially, the way this runs, when a player moves, it tells the server the new location. Upon receiving the new location, the server updates an array of player locations that it contains. The server then broadcasts player locations in the simpleUpdate method. Something I notice is that although the external clients connect successfully, they do not seem to receive any of this location data. Clients run from the host machine, however, do.
The line of the error message that says "An established connection was aborted by the software in your host machine" confuses me, as well. Normally, I would expect this to be the cause of my troubles, but when that client does disconnect, the server still receives a message from it.
Is there enough information here to piece together a solution, or would you prefer to see any of my code?
“Still receives message from it”… are they reliable or unreliable messages?
There is more going on here than meets the eye, I think. Do the TestChatServer and TestChatClient also behave this way on your machines?
I think the first error is somehow inducing a condition in your application that causes broadcasting to run amok. Otherwise I cannot explain why it doesn’t overwhelm memory when you connect locally.
Does the non-local client ever receive updates from the server? Are there any errors when it runs? Are you even capturing the errors there? Are you sure that the client is the right version on the other machine?
If the client never receives a message then it’s because that client has blocked the network packets for some reason or because it is actually failing to read the message and partially crashing or something.
I send the data per frame, but I don’t think that is the issue since it works locally.
They are reliable messages.
The TestChat programs work without issue.
The non-local client receives the data to create the world (Which skybox to use, which terrain to load, etc). They are all strings, and they all load properly. It seems that the simpleUpdate() broadcasts are what isn’t getting through to external clients.
There are absolutely no errors showing up in my client while it’s running, and I’m positive that it is the correct version.
I’d think it was an issue with the firewall as well, but I’ve tried it with firewalls enabled and disabled, and it makes no difference. Those first few messages still get through.
Here is my broadcast code:
[java]
for (int i = 0; i < player.length; i++) {
gameServer.broadcast( new BasicMessage(“plrX”, “” + player.getPlrID(), player.getX()) );
gameServer.broadcast( new BasicMessage(“plrY”, “” + player.getPlrID(), player.getY() - 11.6f) );
gameServer.broadcast( new BasicMessage(“plrZ”, “” + player.getPlrID(), player.getZ()) );
gameServer.broadcast( new BasicMessage(“plrRot”, “” + player.getPlrID(), player.getRot()) );
}
[/java]
gameServer is my Server
I have an array of player objects that I created to store location data named “player”.
BasicMessage sends two strings and a float, since I use it for more than just this purpose. On the other end, I turn the second String into an integer. The first String tells the client listener what the message is, and the float is the actual value.
getX = X Location
getY = Y Location
getZ = Z Location
getRot = Player Rotation (Facing)
The client uses the player’s ID to know which player object to move.
My computer gets 3000fps on basic scenes. If you are trying to send positional data from the client to the server 3000 times a second then it’s going to flood the server. Maybe local can cope (as it will just go over the loopback) but over remote the extra delays are causing problems? Particularly on reliable where any failures need retrying while new messages are piling up behind.
Either way it’s poor network design to send that many messages. You need to cut it down to only sending important things (and really networking comms should be independent from frame rate).
Is there any chance the messages are going over the size limit of messages? (Is there a size limit in spidermonkey?).
Have you tried running up the java monitoring stuff (jconsole) and looking at what memory usage is doing?