zmh-git / pircbotx

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

"ERROR: Trying to reconnect too fast." From server causes PircBotX to get stuck in limbo. #86

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Find an IRC server that throttles incoming connections
2. Make PircBotXs connect to fast after each other
3. Notice "outputThread.sendRawLineNow("USER " + getLogin() + " 8 * :" + 
getVersion());" (PircBotX line 340) throws a RuntimeException
4. Call the connect() method again and notice isConnected() returns true.
5. Try sendMessage() or joinChannel() and notice that the bot isn't really 
connected.

What is the expected output? What do you see instead?
I expect isConnected() to return false if connecting to the server failed due 
to a "ERROR: Trying to reconnect too fast." from the server.

What version of the product are you using? On what operating system?
1.7

Original issue reported on code.google.com by zyor.tae...@gmail.com on 14 Sep 2012 at 12:20

GoogleCodeExporter commented 9 years ago
What is the exception thrown? I would of thought that if the server is trying 
to throttle you from reconnecting it would respond with the error message and 
then close the link, not cause an Exception when writing data to the socket

Original comment by Lord.Qua...@gmail.com on 16 Sep 2012 at 7:16

GoogleCodeExporter commented 9 years ago
The server does respond with said error message and then closes the link. 
However PircBotX doesn't start processing incoming lines until after it tries 
to send the NICK and USER lines. Hence the SocketException occurs:

java.lang.RuntimeException: Exception encountered when writng to socket
    at org.pircbotx.OutputThread.sendRawLineNow(OutputThread.java:71)
    at org.pircbotx.PircBotX.connect(PircBotX.java:340)
    at org.pircbotx.PircBotX.connect(PircBotX.java:231)
Caused by: java.net.SocketException: Broken pipe
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
    at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:202)
    at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:272)
    at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:276)
    at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:122)
    at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:212)
    at java.io.BufferedWriter.flush(BufferedWriter.java:236)
    at org.pircbotx.OutputThread.sendRawLineNow(OutputThread.java:67)

On a sidenote: typo in the RuntimeException message: "writng" :)

Original comment by zyor.tae...@gmail.com on 17 Sep 2012 at 8:50

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Remembered an old IRC server and tried to spam it. No exception. Also tried 
Rizon but I think they simply don't respond after when your throttled. Freenode 
apparently has no throttling or just makes it difficult to trigger

1347897137886 *** Trying address irc.dejatoons.net/209.133.9.43
1347897137947 *** Connected to server.
1347897137947 >>>NICK PircBotX
1347897137947 >>>USER LQ 8 * :PircBotX 1.7, a fork of PircBot, the Java IRC bot 
- pircbotx.googlecode.com
1347897138008 <<<ERROR :Closing Link: [136.165.212.169] (Throttled: 
Reconnecting too fast) -Email http://www.dejatoons.net/forum for more 
information.
1347897138008 *** Logged onto server.
1347897138009 *** Trying address irc.dejatoons.net/209.133.9.43
1347897138070 *** Connected to server.
1347897138071 >>>NICK PircBotX
1347897138071 >>>USER LQ 8 * :PircBotX 1.7, a fork of PircBot, the Java IRC bot 
- pircbotx.googlecode.com
1347897138132 <<<ERROR :Closing Link: [136.165.212.169] (Throttled: 
Reconnecting too fast) -Email http://www.dejatoons.net/forum for more 
information.
1347897138133 *** Logged onto server.
1347897138133 *** Trying address irc.dejatoons.net/209.133.9.43
1347897138195 *** Connected to server.
1347897138196 >>>NICK PircBotX
1347897138196 >>>USER LQ 8 * :PircBotX 1.7, a fork of PircBot, the Java IRC bot 
- pircbotx.googlecode.com
1347897138256 <<<ERROR :Closing Link: [136.165.212.169] (Throttled: 
Reconnecting too fast) -Email http://www.dejatoons.net/forum for more 
information.
1347897138256 *** Logged onto server.

Can you try the most recent snapshot build?

Original comment by Lord.Qua...@gmail.com on 17 Sep 2012 at 3:57

GoogleCodeExporter commented 9 years ago
Ok, I think I've got this fixed in Revision 65e04859f5f6 and Revision 
5acc7839f0ee. Jenkins should push out a snapshot within the next 10 minutes or 
so, can you try it and see if it fixes the problem?

Original comment by Lord.Qua...@gmail.com on 18 Sep 2012 at 2:48

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Almost... except that line 375 catches an IOException but the original 
SocketException (in OutputThread) is wrapped in a RuntimeException and therefor 
not caught in PircBotX.

Original comment by zyor.tae...@gmail.com on 19 Sep 2012 at 9:02

GoogleCodeExporter commented 9 years ago
That should be by design. Just logging the exception there doesn't tell the 
caller that an Exception has occurred; its the equivalent of swallowing it.

Unfortunately in this case since shutdown() is called by the InputThread the 
exception bubbles all the way up to it and just gets logged by the JVM. The 
only thing I can do is dispatch a ReconnectEvent with the exception so at least 
a listener is notified. Added that in Revision 07d71c14e165.

Original comment by Lord.Qua...@gmail.com on 20 Sep 2012 at 7:22

GoogleCodeExporter commented 9 years ago
I'm still having a issue here.

Getting throttled doesn't get handled correctly and causes the onDisconnect() 
event to be called 2 times. Furthermore the bot still thinks it's connected 
after being throttled.

Original comment by jasperve...@gmail.com on 16 Apr 2013 at 8:45