zD12 / pircbotx

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

startBot() method not working as expected #132

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use the startBot() method to continually connect.
2. Unplug your router / modify firewall to deny access to the process.

What is the expected output?
I would expect the bot to throw an IOException that can be handled from the 
call to startBot() as this is unaccessible code in your library.

What do you see instead?
Exception in thread "Thread-3" java.lang.RuntimeException: Couldn't pause 
thread for message delay
    at org.pircbotx.output.OutputRaw.rawLine(OutputRaw.java:67)
    at org.pircbotx.PircBotX.startLineProcessing(PircBotX.java:241)
    at org.pircbotx.PircBotX.connect(PircBotX.java:223)
    at org.pircbotx.PircBotX.startBot(PircBotX.java:141)
    at org.smokinmils.BaseBot$BotThread.run(BaseBot.java:318)
Caused by: java.lang.RuntimeException: Exception encountered when writing to 
socket
    at org.pircbotx.PircBotX.sendRawLineToServer(PircBotX.java:289)
    at org.pircbotx.Utils.sendRawLineToServer(Utils.java:84)
    at org.pircbotx.output.OutputRaw.rawLine(OutputRaw.java:61)
    ... 4 more
Caused by: java.net.SocketException: Connection reset by peer: socket write 
error
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(Unknown Source)
    at java.net.SocketOutputStream.write(Unknown Source)
    at sun.nio.cs.StreamEncoder.writeBytes(Unknown Source)
    at sun.nio.cs.StreamEncoder.implFlushBuffer(Unknown Source)
    at sun.nio.cs.StreamEncoder.implFlush(Unknown Source)
    at sun.nio.cs.StreamEncoder.flush(Unknown Source)
    at java.io.OutputStreamWriter.flush(Unknown Source)
    at org.pircbotx.PircBotX.sendRawLineToServer(PircBotX.java:286)
    ... 6 more

What version of the product are you using? On what operating system?
pircbotx-2.0-20130617.045513-62.jar

Please provide any additional information below.

Original issue reported on code.google.com by Jamie.Re...@gmail.com on 19 Jun 2013 at 3:31

GoogleCodeExporter commented 9 years ago
(side note: Please try to keep issues with the project in the mailing list or 
the Issue tracker. I honestly don't check Google+ that often)

I ran the example bot with a 1 second socket timeout and restarted my router 
but an unable to reproduce that error (problem with the snapshot you were 
using?). I get the expected exception

20:41:26.739 [main] INFO  org.pircbotx.output.OutputRaw - PING 1372207286
20:41:27.741 [main] INFO  org.pircbotx.InputParser - :calvino.freenode.net PONG 
calvino.freenode.net :1372207286
... Internet disconnected ...
20:41:28.743 [main] INFO  org.pircbotx.output.OutputRaw - PING 1372207288
20:41:30.745 [main] INFO  org.pircbotx.output.OutputRaw - PING 1372207290
20:41:32.747 [main] INFO  org.pircbotx.output.OutputRaw - PING 1372207292
20:41:34.750 [main] INFO  org.pircbotx.output.OutputRaw - PING 1372207294
20:41:36.753 [main] INFO  org.pircbotx.output.OutputRaw - PING 1372207296
20:41:38.755 [main] INFO  org.pircbotx.output.OutputRaw - PING 1372207298
20:41:40.466 [main] ERROR org.pircbotx.PircBotX - Exception encountered when 
reading next line from server
java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:189) ~[na:1.7.0_21]
    at java.net.SocketInputStream.read(SocketInputStream.java:121) ~[na:1.7.0_21]
    at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283) ~[na:1.7.0_21]
    at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325) ~[na:1.7.0_21]
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177) ~[na:1.7.0_21]
    at java.io.InputStreamReader.read(InputStreamReader.java:184) ~[na:1.7.0_21]
    at java.io.BufferedReader.fill(BufferedReader.java:154) ~[na:1.7.0_21]
    at java.io.BufferedReader.readLine(BufferedReader.java:317) ~[na:1.7.0_21]
    at java.io.BufferedReader.readLine(BufferedReader.java:382) ~[na:1.7.0_21]
    at org.pircbotx.PircBotX.startLineProcessing(PircBotX.java:237) [classes/:na]
    at org.pircbotx.PircBotX.connect(PircBotX.java:223) [classes/:na]
    at org.pircbotx.PircBotX.startBot(PircBotX.java:140) [classes/:na]
    at org.pircbotx.impl.PircBotXExample.main(PircBotXExample.java:203) [test-classes/:na]
20:41:40.489 [main] INFO  org.pircbotx.dcc.DccHandler - Terminating all 
transfers waiting to be accepted
20:41:40.489 [main] DEBUG org.pircbotx.PircBotX - Disconnected.
20:41:40.489 [main] DEBUG o.p.h.m.ThreadedListenerManager - Waiting for 
listener org.pircbotx.hooks.CoreHooks@6835449e to execute event 
DisconnectEvent(daoSnapshot=org.pircbotx.snapshot.UserChannelDaoSnapshot@7b862bd
b)

However I will say that any output that is pending to be sent but fails WILL 
throw an exception because there's nothing that send() can do about it. 

Original comment by Lord.Qua...@gmail.com on 26 Jun 2013 at 12:48

GoogleCodeExporter commented 9 years ago
Closer inspection of this led me to see it is not the startBot() / connect() 
methods throwing the exceptions but send(). 

I guess I need better exception handling there, however, i'm not sure the bot 
was reconnecting either. I'll look into this more and get back to you if there 
is an actual problem.

Original comment by Jamie.Re...@gmail.com on 27 Jun 2013 at 7:11