Re: [xSocket-develop] ClosedConnectionException
Status: Inactive
Brought to you by:
grro
|
From: Mohamad A. B. A. <az...@gm...> - 2008-05-04 07:34:30
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Gregor,<br>
<br>
Thank you for the explanation. :)<br>
<br>
-Mohamad.<br>
<br>
Gregor Roth wrote:
<blockquote
cite="mid:4c3...@ma..."
type="cite">Hi Mohamad,<br>
<br>
by default the connection and idle timeout of xSocket connections is ~
70 years. To verify that xSocket doesn't close the connection caused by
a timeout, you can implement the ITimout handler interface. The methods
of the timeout handler will be called if a timout occurs. <br>
<br>
Additional you can activate xSocket's log to see what happens under the
hood. <br>
<br>
Please see the example enclosed<br>
<br>
Gregor <br>
<br>
<br>
<br>
public static void main(String[] args) throws IOException {<br>
<br>
Logger logger = Logger.getLogger("org.xsocket.stream");<br>
logger.setLevel(Level.FINE);<br>
<br>
ConsoleHandler ch = new ConsoleHandler();<br>
ch.setLevel(Level.FINE);<br>
logger.addHandler(ch);<br>
<br>
IMultithreadedServer srv = new MultithreadedServer(new
Handler());<br>
// srv.setIdleTimeoutSec(3);<br>
srv.run();<br>
<br>
<br>
}<br>
<br>
<br>
<br>
private static final class Handler implements IDataHandler,
ITimeoutHandler {<br>
<br>
@Override<br>
public boolean onData(INonBlockingConnection connection) throws
IOException, BufferUnderflowException, MaxReadSizeExceededException {<br>
<br>
connection.write(connection.readAvailable());<br>
return true;<br>
}<br>
<br>
@Override<br>
public boolean onConnectionTimeout(INonBlockingConnection
connection) throws IOException {<br>
System.out.println("connection timeout occured (connection
timeout=" + connection.getConnectionTimeoutSec() + ")");<br>
return false; // returning false causes that the
connection will be closed <br>
}<br>
<br>
<br>
@Override<br>
public boolean onIdleTimeout(INonBlockingConnection connection)
throws IOException {<br>
System.out.println("idle timeout occured (idle timeout=" +
connection.getIdleTimeoutSec() + ")");<br>
return false; // returning false causes that the
connection will be closed<br>
}<br>
}<br>
<br>
<br>
<div class="gmail_quote">2008/5/3 Mohamad Azri Bin Azhar <<a
moz-do-not-send="true" href="mailto:az...@gm...">az...@gm...</a>>:<br>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi
there,<br>
<br>
I'm using xSocket 1.2.1 MultithreadedServer to listen for HTTP POST<br>
request. Upon receiving the request, I'd do something with the data<br>
which takes like 1 to 3 seconds and response back to the client.<br>
<br>
Basically, inside my onData() handler, I'd have something like:<br>
<br>
connection.readByteBufferByDelimiter(delimeter);<br>
//do something, and then:<br>
connection.write(someData);<br>
<br>
However, every an hour or so it won't be able to write the response back<br>
and get the following exception:<br>
<br>
org.xsocket.ClosedConnectionException: connection<br>
7c292b5b.119a45810b8.4d6a25b2.s.12074 is already closed<br>
at org.xsocket.stream.Connection.write(Connection.java:667)<br>
at org.xsocket.stream.Connection.write(Connection.java:582)<br>
at<br>
org.xsocket.stream.NonBlockingConnection.onDataEvent(NonBlockingConnection.java:757)<br>
.......<br>
<br>
My question is, does the connection here is closed by xSocket? If so,<br>
any idea to solve this?<br>
<br>
(btw, the client is an Axis client which simply post the request to my<br>
xSocket server)<br>
<br>
Thank you.<br>
<br>
Regards,<br>
Azri.<br>
<br>
<br>
-------------------------------------------------------------------------<br>
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference<br>
Don't miss this year's exciting event. There's still time to save $100.<br>
Use priority code J8TL2D2.<br>
<a moz-do-not-send="true"
href="http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone"
target="_blank">http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone</a><br>
_______________________________________________<br>
xSocket-develop mailing list<br>
<a moz-do-not-send="true"
href="mailto:xSo...@li...">xSo...@li...</a><br>
<a moz-do-not-send="true"
href="https://lists.sourceforge.net/lists/listinfo/xsocket-develop"
target="_blank">https://lists.sourceforge.net/lists/listinfo/xsocket-develop</a><br>
</blockquote>
</div>
<br>
</blockquote>
<br>
</body>
</html>
|