Mar 30, 2008 5:20 PM
Calling session.logout causes IOException
-
Like (0)
I made the following changes to InputThread.java because on trying to call logout I kept getting exceptions. The exception was IOException rather than SocketException so I wonder if using diablo-jdk1.5.0 on FreeBSD 6.1-RELEASE might have some issues interpreting connection issues?
Seemed calling logout should not exception so I wonder what y'all think about this change.
--- src/main/java/org/openymsg/network/InputThread.java (revision 10146)
+++ src/main/java/org/openymsg/network/InputThread.java (working copy)
@@ -69,10 +69,11 @@
try {
process(parentSession.network.receivePacket());
} catch (UnknowServiceException e) {
- log.warn("unknow packet: " + e.getPacket().toString());
+ log.warn("unknown packet: " + e.getPacket().toString());
} catch (Exception e) {
- // ignore SocketExceptions if we're closing the thread.
- if (quit && e instanceof SocketException) {
+ // ignore IOExceptions if we're closing the thread.
+ log.warn("quit: " + quit + " " + e.getMessage());
+ if (quit && e instanceof IOException) {
return;
}
@@ -83,8 +84,8 @@
log.error("error on sendException to the session", e2);
}
- // IO exceptions? Close the connection!
- if (e instanceof IOException) {
+ // SocketExceptions? Close the connection!
+ if (e instanceof SocketException) {
quit = true;
}
}
Clearspace is making a mess out of that patch. Could you please repost the message, (either the diff, or the entire method) and surround it in tags?
Couldn't figure out the rich-text thing so I just used a pastebin
http://java.pastebin.ca/965661
This shows the modified run() method in InputThread.java (package org.openymsg.network). What I did was switch around the handling of SocketException and IOExeception (InterruptedIOException was what I was getting on session.logout())
r
public void run() {
while (!quit) {
try {
process(parentSession.network.receivePacket());
} catch (UnknowServiceException e) {
log.warn("unknown packet: " + e.getPacket().toString());
} catch (Exception e) {
// ignore IOExceptions if we're closing the thread.
log.warn("quit: " + quit + " " + e.getMessage());
if (quit && e instanceof IOException) {
return;
}
log.error("error on process packet", e);
try {
parentSession.sendExceptionEvent(e, "Source: InputThread");
} catch (Exception e2) {
log.error("error on sendException to the session", e2);
}
// SocketExceptions? Close the connection!
if (e instanceof SocketException) {
quit = true;
}
}
}
}
You do this by enclosing your code in two tags that look like this:
I thought maybe it might be of interest to describe what I am trying to do. In retrospect what I am doing makes more sense than what I was trying to do. I would open a session and leave it open for hours. The keep-alive's would keep the connection open for a while, but eventually it seems Y! was shutting down their side of the connection. This shutdown seems pretty regular. What I decided to do was login, send what I needed to send, then logout after a period of time (in another thread). The logout is where the trouble started. Depending on how long I set the timer, I also get repeated socket exceptions when the Keep-alive timer goes off and Yahoo has shut the connection down. I'm trying 10 minutes as the timer atm and we'll see how long that goes. What do others do to handle the drop of the connection by Y! ?
r