使用asmack库和open fire作为服务器注册时出现问题

时间:2012-09-14 07:40:42

标签: android xmpp smack asmack

我使用asmack库在注册时遇到错误。注册代码

Log.d(TAG, "creating new server account...");
                    AccountManager am = new AccountManager(connection);
                    Log.i("Registration Details:","UaerName = "+config.userName + "  Password is ==" + config.password);
                    am.createAccount(config.userName, config.password);

点击我得到的日志:

<main>09-14 12:18:08.132: D/yaxim.SmackableImp(5933): creating new server account...
09-14 12:18:08.142: D/SMACK(5933): 12:18:08 PM SENT (1089044856): <iq id="Ii5WG-0" to="myHost" type="get"><query xmlns="jabber:iq:register"></query></iq>
09-14 12:18:08.522: D/SMACK(5933): 12:18:08 PM RCV  (1089044856): <iq type="result" id="Ii5WG-0" from="myHost"><query xmlns="jabber:iq:register"><username/><password/><email/><name/><x xmlns="jabber:x:data" type="form"><title>XMPP Client Registration</title><instructions>Please provide the following information</instructions><field var="FORM_TYPE" type="hidden"><value>jabber:iq:register</value></field><field var="username" type="text-single" label="Username"><required/></field><field var="name" type="text-single" label="Full name"/><field var="email" type="text-single" label="Email"/><field var="password" type="text-private" label="Password"><required/></field></x></query></iq>
09-14 12:18:08.562: D/SMACK(5933): 12:18:08 PM SENT (1089044856): <iq id="Ii5WG-1" to="myHost" type="set"><query xmlns="jabber:iq:register"><email></email><password></password><username></username><name></name></query></iq>
09-14 12:18:08.933: D/SMACK(5933): 12:18:08 PM RCV  (1089044856): <iq type="error" id="Ii5WG-1" from="myHost" to="myHost/8f0bf952"><query xmlns="jabber:iq:register"><email/><password/><username/><name/></query><error code="500" type="wait"><internal-server-error xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>
09-14 12:18:08.953: I/yaxim.Service(5933): connectionFailed: internal-server-error(500)</main>

这里我有内部服务器错误。错误代码= 500.任何人都可以帮助我。提前谢谢。

我正在使用asmack-issue 15.jar库。

1 个答案:

答案 0 :(得分:6)

我解决了这个问题..在createAccount(config.userName,config.password)中存在问题; smack-issue 15.jar库的方法。

使用createAccount的另一种方法解决了我的问题。

AccountManager am = new AccountManager(mXMPPConnection);
                Log.i("Registration Details:", "UaerName = "
                        + mConfig.userName + "  Password is =="
                        + mConfig.password);
                Map<String, String> mp = new HashMap<String, String>();

                // adding or set elements in Map by put method key and value
                // pair
                mp.put("username", mConfig.userName);
                mp.put("password", mConfig.password);
                mp.put("name", mConfig.userName);
                mp.put("email", "");

                // am.createAccount(mConfig.userName, mConfig.password);
                am.createAccount(mConfig.userName, mConfig.password, mp);