Index: res/res_jabber.c =================================================================== --- res/res_jabber.c (revision 337971) +++ res/res_jabber.c (working copy) @@ -1767,6 +1767,8 @@ case IKS_NODE_START: if (client->state == AJI_DISCONNECTED) { char secret[160], shasum[320], *handshake; + + client->state = AJI_CONNECTING; sprintf(secret, "%s%s", pak->id, client->password); ast_sha1_hash(shasum, secret); @@ -1776,12 +1778,16 @@ ast_free(handshake); handshake = NULL; } - client->state = AJI_CONNECTING; - if (aji_recv(client, 1) == 2) /*XXX proper result for iksemel library on iks_recv of XXX*/ + + /* Upon successful authentication, the server will send empty handshake element, "", + which is proper, but iksemel returns IKS_BADXML; so check for this return code and + indicate we are connected; this probably should be improved upon */ + if (aji_recv(client, 1) == IKS_BADXML) { client->state = AJI_CONNECTED; - else + } else { ast_log(LOG_WARNING, "Jabber didn't seem to handshake, failed to authenticate.\n"); - break; + client->state = AJI_DISCONNECTED; + } } break;