[Home]

Summary:ASTERISK-25735: [patch] res_xmpp: Does not connect in component mode
Reporter:Karsten Wemheuer (kwemheuer)Labels:
Date Opened:2016-02-01 09:54:59.000-0600Date Closed:2016-09-23 14:28:25
Priority:MajorRegression?
Status:Closed/CompleteComponents:Resources/res_xmpp
Versions:11.21.0 Frequency of
Occurrence
Constant
Related
Issues:
Environment:Debian Linux 8, Kernel 4.4, XMPP server Jabberd2 (2.3.4)Attachments:( 0) res_xmpp-component-mode.diff
Description:In asterisk 1.8 we are using res_jabber to connect asterisk with a xmpp server (jabberd2) in *component mode*. In asterisk 11 and newer version res_jabber is deprecated. So I configured the asterisk 11 with res_xmpp in the same way as res_jabber in asterisk 1.8 before. The connection is not established. The module gets immediately unloaded, because the setting of the username “pbx.pbxtest” is not accepted. In res_xmpp there must be a username like xxx@yyy which is wrong according to the xmpp protocol in component mode (XEP-0114).
In res_xmpp.c (line 3705) in function "xmpp_client_config_post_apply" is this peace of code
{noformat}
if (!cfg->client->jid || ast_strlen_zero(cfg->client->jid->user)) {
ast_log(LOG_ERROR, "Jabber identity '%s' could not be created for client '%s' - client not active\n", cfg->user, cfg->name);
return -1;
}
{noformat}
With the attached patch this if statement is skipped in case of component mode. The module accepts the old res_jabber configuration, but the connection is still not established.

If the xmpp server sends out a "stream" element before handshake is finished, the connection gets dropped in res_xmpp. The res_jabber code discards the stream elements and continues the handshaking. The patch  fixes this in function xmpp_component_authenticating.

Another problem is located in function "xmpp_pak_presence". The current code leaves the function directly if there is no resource. A few lines later there is a call to "xmpp_client_set_presence" in case of component mode. This call is not reached, cause in this situation there is no resource. So the patch moves the lines
{noformat}
/* If this is a component presence probe request answer immediately with our presence status */
if (ast_test_flag(&cfg->flags, XMPP_COMPONENT) && !ast_strlen_zero(type) && !strcasecmp(type, "probe")) {
xmpp_client_set_presence(client, pak->from->full, iks_find_attrib(pak->x, "to"), cfg->status, cfg->statusmsg);
}
{noformat}
to the top of the function.

The attached patch fixes the issues with component mode in asterisk 11 (tested with latest release 11.21.0).
Comments:By: Asterisk Team (asteriskteam) 2016-02-01 09:55:01.692-0600

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

By: Karsten Wemheuer (kwemheuer) 2016-02-01 09:58:22.916-0600

Allows connection between res_xmpp and XMPP servers in component mode.

By: Joshua C. Colp (jcolp) 2016-02-01 14:59:59.076-0600

[~kwemheuer] Per the automated comment on this issue if you follow the patch contribution process this will get into the tree faster, otherwise it is up to someone else to take it through the process.

By: Karsten Wemheuer (kwemheuer) 2016-02-02 04:13:11.434-0600

I tried to follow the process. I hope I did it right (its my first gerrit usage).