Những người tốt của StackOverflow, vui lòng trợ giúp. Tôi đã thiết lập máy chủ ejabberd trên máy ubuntu của mình, thêm máy chủ ảo, đặt {access, register, [{allow, all}]}. và đã đăng ký tài khoản quản trị. Tôi không phải là một guru Linux, nhưng tôi đã quản lý để làm điều này thiết lập cơ bản. Bây giờ, từ máy Win 7 của tôi, sử dụng Pidgin, tôi có thể đăng nhập với tư cách quản trị viên và có quyền truy cập vào nhiều tính năng quản trị. Quan trọng nhất tôi có thể tạo người dùng mới trên máy chủ. Vấn đề là tôi không thể làm điều đó với khách hàng Android của tôi bằng cách sử dụng thư viện asmack. Tôi có thể thiết lập kết nối và đăng nhập, nhưng khi tôi cố gắng đăng ký một người dùng mới hoặc quản lý tài khoản trough hoặc bằng cách gửi các gói IQ tôi bị cấm (403) lỗi đáp ứng.asmack XMPP đăng ký người dùng mới
AccountManager am = new AccountManager(connection);
Map<String, String> attributes = new HashMap<String, String>();
attributes.put("username", "my_user_name");
attributes.put("password", "my_password");
attributes.put("email", "[email protected]");
attributes.put("name", "my_full_name");
am.createAccount("my_user_name", "my_password", attributes);
Registration reg = new Registration();
reg.setType(IQ.Type.SET);
reg.setTo(connection.getServiceName());
// attributes.put("username", username);
// attributes.put("password", password);
// reg.setAttributes(attributes);
reg.addAttribute("username", username);
reg.addAttribute("password", password);
reg.addAttribute("email", email);
reg.addAttribute("name", fullName);
PacketFilter filter = new AndFilter(new PacketIDFilter(
reg.getPacketID()), new PacketTypeFilter(IQ.class));
PacketCollector collector = connection.createPacketCollector(filter);
connection.sendPacket(reg);
Có ai có vấn đề tương tự hoặc có thể cho tôi biết tôi đang làm gì sai?
Cảm ơn
Đây là LogCat tôi
10-10 10:00:26.249: DEBUG/StatusBarPolicy(1639): [BRIGHTHY] curNetwork=22003 curHPLMN=22003
10-10 10:00:26.839: INFO/System.out(21277): 10:00:26 AM SENT (1080244736): <iq id="fMJxx-4" to="morena.local" type="get"><query xmlns="jabber:iq:register"></query></iq>
10-10 10:00:26.869: INFO/System.out(21277): 10:00:26 AM RCV (1080244736): <iq from='morena.local' to='[email protected]/Smack' id='fMJxx-4' type='result'><query xmlns='jabber:iq:register'><instructions>Choose a username and password to register with this server</instructions><username>admin</username><password/><registered/></query></iq>
10-10 10:00:26.959: INFO/System.out(21277): 10:00:26 AM SENT (1080244736): <iq id="fMJxx-5" to="morena.local" type="set"><query xmlns="jabber:iq:register"><password>new_user</password><username>[email protected]</username></query></iq>
10-10 10:00:26.969: INFO/System.out(21277): 10:00:26 AM RCV (1080244736): <iq from='morena.local' to='[email protected]/Smack' id='fMJxx-5' type='error'><query xmlns='jabber:iq:register'><password>new_user</password><username>[email protected]</username></query><error code='403' type='auth'><forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>
10-10 10:00:31.659: WARN/System.err(21277): forbidden(403)
10-10 10:00:31.659: WARN/System.err(21277): at org.jivesoftware.smack.AccountManager.createAccount(AccountManager.java:246)
10-10 10:00:31.659: WARN/System.err(21277): at org.jivesoftware.smack.AccountManager.createAccount(AccountManager.java:207)
10-10 10:00:31.659: WARN/System.err(21277): at org.me.my_project.FriendProfileActivity.connectToServer(FriendProfileActivity.java:698)
10-10 10:00:31.659: WARN/System.err(21277): at org.me.my_project.FriendProfileActivity.connectLogin(FriendProfileActivity.java:578)
10-10 10:00:31.659: WARN/System.err(21277): at org.me.my_project.FriendProfileActivity$2.run(FriendProfileActivity.java:433)
10-10 10:00:31.659: INFO/System.out(21277): 10:00:31 AM SENT (1080244736): <iq id="fMJxx-6" to="morena.local" type="get"><query xmlns="jabber:iq:register"></query></iq>
10-10 10:00:31.679: INFO/System.out(21277): 10:00:31 AM RCV (1080244736): <iq from='morena.local' to='[email protected]/Smack' id='fMJxx-6' type='result'><query xmlns='jabber:iq:register'><instructions>Choose a username and password to register with this server</instructions><username>admin</username><password/><registered/></query></iq>
10-10 10:00:31.689: INFO/System.out(21277): 10:00:31 AM SENT (1080244736): <iq id="fMJxx-7" to="morena.local" type="set"><query xmlns="jabber:iq:register"><email>[email protected]</email><password>new_user1</password><username>[email protected]</username><name>[email protected]</name></query></iq>
10-10 10:00:31.699: INFO/System.out(21277): 10:00:31 AM RCV (1080244736): <iq from='morena.local' to='[email protected]/Smack' id='fMJxx-7' type='error'><query xmlns='jabber:iq:register'><email>[email protected]</email><password>new_user1</password><username>[email protected]</username><name>[email protected]</name></query><error code='403' type='auth'><forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>
10-10 10:00:31.729: WARN/System.err(21277): forbidden(403)
10-10 10:00:31.729: WARN/System.err(21277): at org.me.my_project.utilities.CreateChatAccount.createAccount(CreateChatAccount.java:100)
10-10 10:00:31.729: WARN/System.err(21277): at org.me.my_project.utilities.CreateChatAccount.createAccount(CreateChatAccount.java:143)
10-10 10:00:31.729: WARN/System.err(21277): at org.me.my_project.FriendProfileActivity.connectToServer(FriendProfileActivity.java:706)
10-10 10:00:31.729: WARN/System.err(21277): at org.me.my_project.FriendProfileActivity.connectLogin(FriendProfileActivity.java:578)
10-10 10:00:31.729: WARN/System.err(21277): at org.me.my_project.FriendProfileActivity$2.run(FriendProfileActivity.java:433)
có thể điều này có thể giúp –
trên máy tính của bạn, bạn có chắc chắn tường lửa của bạn không chặn cổng 5222? – Maggie
bạn giải quyết vấn đề này? – CoronaPintu