Subject: | Handshake errors while connecting to Google Talk with XMPP over TLS |
I use POE::Component::Jabber::Client::XMPP to connect to Google's servers. In about one out of three attempts to connect, I get a 'handshake error' from the POE::Component::Jabber::Client::XMPP::TLS.
It could be my network configuration. It could also be a bug in openSSL.
I have included a small sample app, which demonstrates the problem. It will write "handshake error" to STDERR if the TLS socket connection fails.
#!/app/im/bin/perl -w
use strict;
use POE;
use POE::Component::Jabber::Client::XMPP qw();
POE::Session->create
(
inline_states => {
_start => \&handler_start,
_stop => \&handler_stop,
jam_init_finished => \&jam_init_finished,
jam_input_event => \&jam_input_event,
jam_error_event => \&jam_error_event,
}
);
POE::Kernel->run();
exit;
sub handler_start {
my ($kernel, $session) = @_[ KERNEL, SESSION ];
print "Handler start\n";
$kernel->alias_set( 'mainS' );
POE::Component::Jabber::Client::XMPP->new
(IP => 'talk.google.com',
PORT => '5222',
HOSTNAME => 'gmail.com',
USERNAME => 'gtalkie',
PASSWORD => 'xxxxxxx',
RESOURCE => 'handshake_tester',
ALIAS => 'xmppS',
DEBUG => 0,
STATE_PARENT => 'mainS',
STATES => {
InitFinish => 'jam_init_finished',
InputEvent => 'jam_input_event',
ErrorEvent => 'jam_error_event',
}
);
}
sub handler_stop {
print "Handler stop\n";
}
sub jam_init_finished {
my $kernel = $_[KERNEL];
print "jam_init_finished\n";
$kernel->post('xmppS', shutdown_socket => 0);
}
sub jam_input_event {
}
sub jam_error_event {
print "jam_error_event\n";
}