Home: Perl Programming Help: Intermediate:
Can't locate method "push_write"

New User

Jan 2, 2013, 5:31 AM

Views: 4137
Can't locate method "push_write"

Hi there!

I'm trying to send a message via XMPP, but I only get the error:

Can't locate object method "push_write" via package "AnyEvent::Util::guard" at /usr/local/share/perl/5.14.2/AnyEvent/XMPP/SimpleConnection.pm line 113.

All needed modules are installed and I don't know what's wrong here.

This is the script:

use utf8;
use AnyEvent;
use AnyEvent::XMPP::IM::Connection;
use AnyEvent::XMPP::IM::Presence;
use AnyEvent::XMPP::Util qw/split_jid/;

my $con =
AnyEvent::XMPP::Connection->new (
username => "root",
domain => "perlx.de",
hostname => "localhost",
password => "123458765",
resource => "Blubb"

$con->reg_cb (stream_ready => sub { print "bereit!\n" });

AnyEvent::XMPP::IM::Message->new (
body => "test",
to => "tk@perlx.de"
)->send ($con);

I am grateful for any help.

Veteran / Moderator

Jan 2, 2013, 6:44 AM

Views: 4133
Re: [tobi] Can't locate method "push_write"

Are you sure all needed modules are installed and were installed without errors?

The "push_write" method is defined in the AnyEvent::Handle module. I have not looked at each of the modules you are loading to see which one, if any, load that module, but start by adding it to your list of use statements.

You should also add the warnings and strict pragmas, which should be in every script you write.

New User

Jan 2, 2013, 11:10 PM

Views: 4113
Re: [FishMonger] Can't locate method "push_write"

Thank's for your reply FishMonger!

Modues where all installed with "make test -- OK" and "make install -- OK".

Actualy it didn't run because I'm too soopid:
I invoked send() after reg_cb() was finished.
Instead, this works for me:

 $con->reg_cb ( 
AnyEvent::XMPP::IM::Message->new (
)->send ($con);

Best regards