Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (600)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Connection was forcibly closed by Client  (Read 1868 times)
0 Members and 1 Guest are viewing this topic.
Offline seu

Junior Newbie





« Posted 2007-05-02 00:31:57 »

Hi,

 I'm having a problem with my client connecting to the server, and i haven't found any clue searching the posts, so here it goes...

 I have a very simple server similar to the HelloUser example. I'm running it from within Eclipse with no problems. Startup log says:
Quote
May 1, 2007 9:16:48 PM com.sun.sgs.impl.kernel.Kernel <init>
INFO: The Kernel is ready, version: 0.9.1-r2129
May 1, 2007 9:16:50 PM com.sun.sgs.impl.kernel.Kernel applicationReady
INFO: FreeTraveller: application is ready

 When I try to connect with my (also very simple) client, y get this:
Quote
ay 1, 2007 9:16:57 PM com.sun.sgs.impl.service.session.ClientSessionImpl$Listener exceptionThrown
WARNING: Handler.exceptionThrown handle:com.sun.sgs.impl.io.SocketConnection@95fd19
java.io.IOException: An existing connection was forcibly closed by the remote host
   at sun.nio.ch.SocketDispatcher.read0(Native Method)
   at sun.nio.ch.SocketDispatcher.read(Unknown Source)
   at sun.nio.ch.IOUtil.readIntoNativeBuffer(Unknown Source)
   at sun.nio.ch.IOUtil.read(Unknown Source)
   at sun.nio.ch.SocketChannelImpl.read(Unknown Source)
   at org.apache.mina.transport.socket.nio.SocketIoProcessor.read(Unknown Source)
   at org.apache.mina.transport.socket.nio.SocketIoProcessor.process(Unknown Source)
   at org.apache.mina.transport.socket.nio.SocketIoProcessor.access$4(Unknown Source)
   at org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(Unknown Source)
   at org.apache.mina.util.NamePreservingRunnable.run(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

The client just does this to connect:
Quote
...
client = new SimpleClient(this);
      Properties connectProps = new Properties();
      connectProps.setProperty("host", "localhost");
      connectProps.setProperty("port", "1139");
      
      try {
         System.out.println("pre login");
         client.login(connectProps);
         System.out.println("post login");
      } catch (IOException e) {
         e.printStackTrace();
      }
...

The server is running at localhost, port 1139 (but the connection is received and *then* shutdown by the client, so that info is ok). OS is Windows XP. I suspect either some kind of operating system/permission/security problem (but i even shut down the firewall to test this), or maybe some Eclipse thing with two apps. running inside trying to connect to each other (I'll try running some - or both - outside Eclipse). Could someone hint me on where could I look for the problem?

Thanks

---<br />Sebastián Uribe<br />Inmune Games
Offline Jeff

JGO Coder




Got any cats?


« Reply #1 - Posted 2007-05-02 01:46:16 »

Is that exception on the client or the server?

That makes a big difference.

My wild guess at the moment is that the exception is on the client, and the cause is that you are returning NULL for your session listener from the loggedIn() callback on the server side.

This indicates a rejection of the user by the server app code and it forceably disconnects the client.

This *should* be in the both the API docs and the tutorial...

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline seu

Junior Newbie





« Reply #2 - Posted 2007-05-02 13:14:40 »

Is that exception on the client or the server?

That makes a big difference.

My wild guess at the moment is that the exception is on the client, and the cause is that you are returning NULL for your session listener from the loggedIn() callback on the server side.

This indicates a rejection of the user by the server app code and it forceably disconnects the client.

This *should* be in the both the API docs and the tutorial...

It's on the client. I don't have the code right now, but I'm pretty sure I created a ClientSessionListener (actually, a class that inherits from it) that is returned in the loggedIn. It's also being added to a List, so I think if it was null I should get an NPE before even returning it. I will check my code again, and try to run the examples too.
Thanks.

---<br />Sebastián Uribe<br />Inmune Games
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jeff

JGO Coder




Got any cats?


« Reply #3 - Posted 2007-05-02 18:24:57 »

Make sure to enable logging.  (Look in the logging.properties file for directions or in the server tutorial.)

You may be exceptioning on the server and not knowing it.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline seu

Junior Newbie





« Reply #4 - Posted 2007-05-02 23:12:15 »

Make sure to enable logging.  (Look in the logging.properties file for directions or in the server tutorial.)

You may be exceptioning on the server and not knowing it.

Ok, i've got it. Thing is, after calling client.login(connectProps), my client application's main method ended. I assumed that the client libraries would wait for a response, so I had some loop code at the loggedIn() method just waiting to be invoked. But it seems the application ended before the code was even invoked.
As the examples are Swing from the client side, and Swing has it's own thread maintaining the application running, the problem could not be noticed.

Now I have some thread waiting for the connection. Anyway I still have something strange happening with the threads in the client side, I think I'm still not getting exactly how this (asynchronous?) communication from the client should be handled, but I know where to look at. Smiley


---<br />Sebastián Uribe<br />Inmune Games
Offline Jeff

JGO Coder




Got any cats?


« Reply #5 - Posted 2007-05-03 02:27:10 »

Yeah, communication in the client side Java API comes in asynchronously.  A common Java mechanism though counter-intuitive I'd admit for most experienced game programmers.

In bunny hunters I just queued the incoming packet and then handled the queue in my main game loop.

Of course, if your client app is Swing, that implies an event driven rather then loop driven client, yes?

Anyway anything I can help with please feel free to ask.


Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (29 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (40 views)
2014-12-09 22:41:13

BurntPizza (75 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (50 views)
2014-12-03 16:27:13

CopyableCougar4 (47 views)
2014-11-29 21:32:03

toopeicgaming1999 (113 views)
2014-11-26 15:22:04

toopeicgaming1999 (100 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!