kirsle / aires-bot

A multiprotocol Perl chatbot for AIM, Yahoo and others.
GNU General Public License v2.0
5 stars 0 forks source link

No such device or address when connecting to xmpp server #1

Open StuartJMackintosh opened 6 years ago

StuartJMackintosh commented 6 years ago

Hello,

I have set up aires-bot but can't get it to connect to the xmpp server. For testing, I am using an account on xmpp.xyz which works from Pidgin.

The following error is returned;

XMPP disconnected: AnyEvent::XMPP::Client=HASH(0x563bc96e7410) AnyEvent::XMPP::IM::Account=HASH(0x563bc954a0c0) Couldn't create socket to xmpp.xyz:xmpp-client=5222: No such device or address

The log looks like this:


-== AiRS - Artificial Intelligence/RiveScript ==-

== Reading configuration files ==
:: Reading: conf/botmaster.json
:: Reading: conf/colors.json
== Reading chatterbot settings ==
:: Reading: bots/Sample.json
== Initializing chatterbot brains ==
:: Loading brain "RiveScript" for bot "Sample"
== Initializing chatterbot listeners (mirrors) ==
:: Loading listener "XMPP" for bot "Sample"
   Creating mirror: XMPP-chatbot-test@xmpp.xyz

I am aware of the reimplementation in Python but Perl is preferable so would be good to get this going as it seems to do just what I need. Any help would be appreciated, let me know if you need anything else to help debug this.

Thanks!

Stuart.

kirsle commented 6 years ago

I think it's a config issue. The XMPP resource name goes into the "resource" key instead of being included in the mirror username. The mirror username is just the XMPP email address on its own.

Example:

  "XMPP": {
    # XMPP shared settings.
+   "resource": "xmpp-client",

    # Mirrors.
    "mirrors": [
        # Remove the "#" below and fill in your XMPP bot's
        # information to sign on an XMPP bot.
        {
-           "username": "chatbot-test@xmpp.xyz:xmpp-client",
+           "username": "chatbot-test@xmpp.xyz",
            "password": "*****"
        },
    ]
  },
StuartJMackintosh commented 6 years ago

Thanks for the quick response Noah.

This is how I already had it set up with minor layout differences but made the change as you suggest anyway with the addition of my password and have the very same error.

I can add debugging if you can give me some pointers of things that would be useful.

kirsle commented 6 years ago

Yeah debugging may help. I was looking at the original error message:

Couldn't create socket to xmpp.xyz:xmpp-client=5222: No such device or address

It looks like a socket error of the form Couldn't create socket to <hostname>:<port>: No such device or address, only here, <hostname> is xmpp.xyz and <port> is the string xmpp-client=5222 when it should've been just the port number 5222

So somewhere along the way it's getting an extra xmpp-client= prefix on the port number, and then the text "xmpp-client" itself made me think it was the XMPP resource name.

A DNS resolution or network error should look more like:

Couldn't create socket to xmpp.xyz:5222: No such device or address

StuartJMackintosh commented 6 years ago

Thanks for the suggestion, I will investigate what is happening to the port number on the way to AnyEvent and report back shortly.

StuartJMackintosh commented 6 years ago

AnyEvent XMPP connection line 112: https://github.com/yannk/perl-anyevent-xmpp/blob/master/lib/AnyEvent/XMPP/Connection.pm


=item port => $port
This is optional, the default value for C<$port> is 'xmpp-client=5222', which
will used as C<$service> argument to C<tcp_connect> of L<AnyEvent::Socket>.
B<NOTE:> If you specify the port number here (instead of 'xmpp-client=5222'),
B<no> DNS SRV lookup will be done when connecting.

So this is a legitimate configuration but maybe I am missing a library for SRV lookups or something to usefully use the 'service' setting.