Trouble connecting to Slack IRC

464 views
Skip to first unread message

Steve Barber

unread,
May 19, 2014, 5:55:58 PM5/19/14
to pirc...@googlegroups.com
Any idea if I'm doing something wrong, or if there's just some weirdness with this IRC server? SSL, with a password.

2014-05-19 17:48:59.254-0400 [Thread- ThreadPool - 3] INFO  org.pircbotx.PircBotX - Connected to server.
2014-05-19 17:48:59.257-0400 [Thread- ThreadPool - 3] INFO  org.pircbotx.output.OutputRaw - CAP LS
2014-05-19 17:48:59.258-0400 [Thread- ThreadPool - 3] INFO  org.pircbotx.output.OutputRaw - PASS mypass
2014-05-19 17:48:59.258-0400 [Thread- ThreadPool - 3] INFO  org.pircbotx.output.OutputRaw - NICK myname
2014-05-19 17:48:59.258-0400 [Thread- ThreadPool - 3] INFO  org.pircbotx.output.OutputRaw - USER myname 8 * :PircBotX 2.0.1, a fork of PircBot, the Java IRC bot - pircbotx.googlecode.com
2014-05-19 17:48:59.307-0400 [Thread- ThreadPool - 3] INFO  org.pircbotx.InputParser - :slackbot PRIVMSG myname : VERSION
2014-05-19 17:48:59.320-0400 [Thread- ThreadPool - 3] INFO  org.pircbotx.InputParser - :irc.tinyspeck.com 004 irc.tinyspeck.com IRC-SLACK gateway
2014-05-19 17:49:00.259-0400 [Thread- ThreadPool - 3] INFO  org.pircbotx.output.OutputRaw - JOIN #test 
2014-05-19 17:49:00.267-0400 [Thread- ThreadPool - 3] ERROR org.pircbotx.PircBotX - Exception encountered when parsing line
java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
at java.util.ArrayList.RangeCheck(ArrayList.java:547) ~[na:1.6.0_45]
at java.util.ArrayList.get(ArrayList.java:322) ~[na:1.6.0_45]
at org.pircbotx.ServerInfo.parse004(ServerInfo.java:115) ~[pircbotx-2.0.1.jar:na]
at org.pircbotx.ServerInfo.parse(ServerInfo.java:106) ~[pircbotx-2.0.1.jar:na]
at org.pircbotx.InputParser.processServerResponse(InputParser.java:709) ~[pircbotx-2.0.1.jar:na]
at org.pircbotx.InputParser.handleLine(InputParser.java:323) ~[pircbotx-2.0.1.jar:na]
at org.pircbotx.PircBotX.startLineProcessing(PircBotX.java:275) [pircbotx-2.0.1.jar:na]
at org.pircbotx.PircBotX.connect(PircBotX.java:236) [pircbotx-2.0.1.jar:na]
at org.pircbotx.PircBotX.startBot(PircBotX.java:151) [pircbotx-2.0.1.jar:na]
at com.blah.adapter.irc.IRCOutputAdapter.connect(IRCOutputAdapter.java:199) [java-bin/:na]
        [ . . . . .]
2014-05-19 17:49:01.261-0400 [listenerPool0-thread1] INFO  org.pircbotx.output.OutputRaw - NOTICE slackbot : VERSION PircBotX 2.0.1, a fork of PircBot, the Java IRC bot - pircbotx.googlecode.com
2014-05-19 17:49:01.332-0400 [Thread- ThreadPool - 3] INFO  org.pircbotx.InputParser - :slackbot PRIVMSG myname :SSL connection required
2014-05-19 17:49:01.333-0400 [Thread- ThreadPool - 3] INFO  org.pircbotx.InputParser - 444 sbarber :SSL connection required
2014-05-19 17:49:01.350-0400 [Thread- ThreadPool - 3] INFO  org.pircbotx.dcc.DccHandler - Terminating all transfers waiting to be accepted


Code:

private void connect() {
        Configuration configuration = new Configuration.Builder()
        .setName(getName()) //Set the nick of the bot.
        //TODO: separate username and nick properties
        .setLogin(getName()) //login part of hostmask, eg name:login@host
        .setAutoNickChange(true) //Automatically change nick when the current one is in use
        .setCapEnabled(true) //Enable CAP features
        .addCapHandler(new TLSCapHandler(new UtilSSLSocketFactory().trustAllCertificates(), true))
        .setServer(getServer(), getPort(), getPassword()) //TODO: handle servers that don't require a password
        .addAutoJoinChannel(getTarget()) //Join the configured channel
        .buildConfiguration();
        
try {
       bot = new PircBotX(configuration);
       bot.startBot();
       
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
connected = false;
return;
} catch (IrcException e) {
// TODO Auto-generated catch block
e.printStackTrace();
connected = false;
return;
}
connected = true;
}


Leon Blakey

unread,
May 19, 2014, 6:09:26 PM5/19/14
to pirc...@googlegroups.com
The exception is from a bug reported last week in 2.0.1 where servers with non-standard 004 responses break ServerInfo. You can safely ignore it until 2.1 comes out

Your problem is the line :slackbot PRIVMSG myname :SSL connection required

In your code your using TLSCapHandler which connects to the server over a plain unencrypted connection, and if the server supports it (yours doesn't), upgrades the connection to SSL. What your server seems to be wanting is a SSL connection from the start.

Just replace this:
.addCapHandler(new TLSCapHandler(new UtilSSLSocketFactory().
trustAllCertificates(), true))

with this:
.setSocketFactory(new UtilSSLSocketFactory().trustAllCertificates())

You'll might have to change the port as well to one of the servers SSL ports

-Leon


--
You received this message because you are subscribed to the Google Groups "pircbotx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pircbotx+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Steve Barber

unread,
May 20, 2014, 8:02:41 AM5/20/14
to pirc...@googlegroups.com
Yes, indeed the server does very much want an SSL connection from the start.

Thanks very much! It is connected now.

If you are interested in testing your 2.1 ServerInfo parsing fix against the server I'm using, just go to https://slack.com/ and create yourself an account, and enable IRC connections. If you don't know Slack, it is getting popular in some circles. I suspect I won't be the last to want to connect to it with PircBotX.

-Steve

Reply all
Reply to author
Forward
0 new messages