Releasing socket on server when client socket has been closed.

28 views
Skip to first unread message

Christian

unread,
Feb 13, 2013, 9:04:48 AM2/13/13
to naga-...@googlegroups.com
Hello Naga users,

here is my situation, maybe you know where the problem is situated or what I could check to pinpoint the issue:
  1. In my naga project I have a client that establishes a tcp connection with naga to a tcp server.
  2. The server itself is not implemented with naga and I do not have control over it.
  3. I can querry the server to list me all sockets that have established a socket connection with the server
  4. Sending  data to and receiving data from the server works fine except that the sockets on the server side does not getting released if I call "close()" on the NIOSocket interface of my client.
  5. I can see that the socket on the serverside has still established a connection, as well the NIOSocket.isOpen() method returns true.
  6. If I directly access the underlying socket through NIOSocket.socket() and call "close()" on that client-socket it will released correctly on the server side.
  7. If I implement this test scenario without naga with plain java sockets, calling "close()" on the client-socket will also release the socket on the server side.

Do you have an explanation for this behavior? And furthermore I would like to know if calling "close" on the underlying/wrapped socket will cause any trouble.


Thank you for your hints

Christian

Christoffer Lernö

unread,
Feb 13, 2013, 11:45:12 AM2/13/13
to naga-...@googlegroups.com
That sounds like the CloseEvent isn't run. Do you continue to do selectBlocking / selectNonBlocking on the client NIOService after close? Otherwise the CloseEvent (which is supposed to run on the NIOService thread), isn't called and the socket isn't closed.

If that's the error, then this also suggests that you might be running multiple NIOService instances? That's usually not necessary.

/Christoffer

P.S. Calling close on the underlying socket will work, but like I said it sounds like you're terminating NIOService early. I recommend fixing that instead.
> --
> You received this message because you are subscribed to the Google Groups "Naga Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to naga-users+...@googlegroups.com.
> To post to this group, send email to naga-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/naga-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Christian

unread,
Feb 14, 2013, 7:11:29 AM2/14/13
to naga-...@googlegroups.com
Yes, you are right I have multiple NIOService instances running at the same time. With your hints I am looking forward to "singleton" my NIOService. I will leave a reply as soon as I tested this.

Thanks for your help.

Christoffer Lernö

unread,
Feb 14, 2013, 7:32:33 AM2/14/13
to naga-...@googlegroups.com
No problem. 

Let me know if you encounter any further issues.

Sent from my iPhone
Reply all
Reply to author
Forward
0 new messages