raisedragon / pircbotx

Automatically exported from code.google.com/p/pircbotx
0 stars 0 forks source link

Bot can't detect if connection dies, gives up on reconnect after one attempt(?) #115

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
>>What steps will reproduce the problem?
1. Run the bot
2. Have network disconnect, wait 15-20 minutes or so (that's how long it takes 
until the bot notices it isn't connected to anything as far as I can tell).
3. java.net.SocketException in inputthread. http://pastebin.com/pWxHgGUE

>>What is the expected output? What do you see instead?
I expect the bot to do reconnect attempts until it connects without the input 
thread dying and making another reconnect "impossible".

>>What version of the product are you using? On what operating system?
This error is present in at least 1.8 and all 1.9 dev versions. On both Ubuntu 
and on W7. Running Java 1.7 32 and 64 bit versions.

>>Please provide any additional information below.
Note that I'm having trouble replicating the exact error that is causing me so 
much trouble. There are several ways to get the bot to fire a error that is not 
recoverable from regarding disconnects/reconnects however. The one in the 
pastebin is the one that I get once every week or so.

Full error with some time stamps in pastebin.
I included some errors from the twitter api I'm using so you can see how long 
it takes, I'm GMT+1.
feb 06, 2013 4:58:45 <- Twitter disconnects. (Since this is a stream it notices 
this fairly fast.)
feb 06, 2013 4:58:46 <- Twitter reconnects.
1360124574188 = feb 06  2013 5:22:54 GMT <- PircbotX error.

Other errors I can produce by disconnecting (???):

If you just pull the plug, let the bot go through all the server IP's it has 
and fire a disconnect and a reconnect event (couple of seconds?) it will tell 
you the following:
Exception in thread "bot1-input" java.lang.RuntimeException: Can't reconnect to 
server
    at org.pircbotx.PircBotX.shutdown(PircBotX.java:2872)
    at org.pircbotx.PircBotX.shutdown(PircBotX.java:2815)
    at org.pircbotx.InputThread.run(InputThread.java:117)
Caused by: java.io.IOException: Can't connect to server
    at org.pircbotx.PircBotX.connect(PircBotX.java:440)
    at org.pircbotx.PircBotX.reconnect(PircBotX.java:472)
    at org.pircbotx.PircBotX.shutdown(PircBotX.java:2866)
    ... 2 more
Caused by: java.net.UnknownHostException: irc.esper.net
    at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
    at java.net.InetAddress$1.lookupAllHostAddr(Unknown Source)
    at java.net.InetAddress.getAddressesFromNameService(Unknown Source)
    at java.net.InetAddress.getAllByName0(Unknown Source)
    at java.net.InetAddress.getAllByName(Unknown Source)
    at java.net.InetAddress.getAllByName(Unknown Source)
    at org.pircbotx.PircBotX.connect(PircBotX.java:289)
    ... 4 more

Then as you plug the cable back in:

Exception in thread "bot1-input" java.lang.RuntimeException: Can't reconnect to 
server
    at org.pircbotx.PircBotX.shutdown(PircBotX.java:2872)
    at org.pircbotx.PircBotX.shutdown(PircBotX.java:2815)
    at org.pircbotx.InputThread.run(InputThread.java:117)
Caused by: java.io.IOException: Can't connect to server
    at org.pircbotx.PircBotX.connect(PircBotX.java:440)
    at org.pircbotx.PircBotX.reconnect(PircBotX.java:472)
    at org.pircbotx.PircBotX.shutdown(PircBotX.java:2866)
    ... 2 more
Caused by: java.net.SocketException: Socket is closed
    at java.net.Socket.getInputStream(Unknown Source)
    at org.pircbotx.PircBotX.connect(PircBotX.java:315)
    ... 4 more

and not reconnect after all. I believe the point of a reconnect feature is not 
to crash when the internet dies for a split second.

PircBotX settings for both errors:
        tbot.setVerbose(true);
        tbot.setAutoNickChange(true);
        tbot.setAutoReconnect(true);
        tbot.setMessageDelay(100);
        tbot.setAutoSplitMessage(true);
        tbot.useShutdownHook(true);
        tbot.setCapEnabled(false);

Best Regards and good luck.

Original issue reported on code.google.com by Tnade...@gmail.com on 6 Feb 2013 at 8:08

GoogleCodeExporter commented 9 years ago
Gave as much info as I could.. but it seems to be happening at 3-4am every time 
and I'm rarely up to see what the problem is :/ 
This has been a reoccurring issue for me since 1.6 (when I started using it). 
I have a Teamviewer (remove desktop) connection to the computer in question 
that doesn't die when the bot does. 
I'll submit more error reports as I find them.

Original comment by Tnade...@gmail.com on 6 Feb 2013 at 8:13

GoogleCodeExporter commented 9 years ago
So I think I found the "problem".
This is what happens at the time of the disconnect:
http://paste.ubuntu.com/1615741/
Aka, my IP runs out and I'm handed a new one by the router. I've put down a 
static ip for now but I don't see why this should be necessary. 

Original comment by Tnade...@gmail.com on 6 Feb 2013 at 8:33

GoogleCodeExporter commented 9 years ago
Sorry, I've been busy lately.

It shouldn't take 20-30 minutes for the bot to realize that its timed out. I 
tested with a 30 sec socket timeout and a couple of seconds after it sent the 
ping line, the input thread died with a connection reset SocketException. 

Can you try adding tbot.setSocketTimeout(1000 * 30); and see if that helps your 
problem?

Original comment by Lord.Qua...@gmail.com on 18 Feb 2013 at 10:29

GoogleCodeExporter commented 9 years ago
Haven't gotten a response, is this still an issue? 

The latest dev version also fixes some problems with bot shutdown, can you give 
it a try?
https://code.google.com/p/pircbotx/wiki/DevVersion

Original comment by Lord.Qua...@gmail.com on 1 Mar 2013 at 9:27

GoogleCodeExporter commented 9 years ago
I have yet to have a "real" disconnect but in my tests the bot seems to handle 
it better. I can reopen this if I have the issue again but you can close it for 
now.
Sorry for the late reply, I've been lazy with my email box.

Original comment by Tnade...@gmail.com on 11 Mar 2013 at 10:51

GoogleCodeExporter commented 9 years ago
That's fine. Let us know if the problem comes up again

Original comment by Lord.Qua...@gmail.com on 11 Mar 2013 at 10:52