Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XMPP aSmack MultiUserChat server continues to send already received messages

I'am a new user on stack, but I have a problem with MultiUserChat in aSmack library 3.2.1 for android. I'm using "gtalk.google.com" server. It's a simple example and I'am only one in room:

 String room="[email protected]";
 MultiUserChat muc = new MultiUserChat(connection,room);
 muc.join(userNameInRoom);

 muc.addMessageListener(new PacketListener()
 {
    @Override
    public void processPacket(Packet packet)
    {
         ...
    }
 });

After:

 muc.sendMessage("Text message");

In Log:

DEBUG/SMACK(281): 06:46:29 PM SENT (1140866576): <message id="gsMe7-18"
to="[email protected]" type="groupchat"><body>Text message
</body></message>

DEBUG/SMACK(281): 06:46:29 PM RCV  (1140866576): <message
from="[email protected]/userNameInRoom" to="userName"
type="groupchat"><body>Text message</body></message>

Result: "Text message" and it is right, but then:

I again recieved "Text message" with presences:

DEBUG/SMACK(281): 06:54:12 PM RCV  (1140866576): <presence 
from="[email protected]/userNameInRoom" to="userName"><x xmlns=
"vcard-temp:x:update"><photo/></x><x xmlns="http://jabber.org/protocol/muc#user">
<item affiliation="owner" role="moderator"/><status code="110"/></x></presence>

DEBUG/SMACK(281): 06:54:12 PM RCV  (1140866576): <message 
from="[email protected]/userNameInRoom" to="userName"
type="groupchat"><body>Text message</body><delay stamp="2012-02-15T17:46:31Z" 
from="[email protected]" xmlns="urn:xmpp:delay"/><x 
stamp="20120215T17:46:31" from="[email protected]" 
xmlns="jabber:x:delay"/></message>

And I recieved that again and again whenever server send presences to me. It continues infinitely with interval ~ 5 minutes. And Yes in 30 minutes I recieved ~6 messages "Text message". If I send more than 1 message all of these messages would been recieved without exceptions when presence send to me.

What problem with my MultiUserChat and what delayed delivery doing here?

Thanks for attention!

like image 498
nizhney Avatar asked Oct 09 '22 16:10

nizhney


2 Answers

In case of "@conference.jabber.org" I didn't find solution and I decided that problem because of GTalk server and correct version of MultiUserChat is in case with "@groupchat.google.com".

I changed my code from:

room=roomName+"@conference.jabber.org";
MultiUserChat muc = new MultiUserChat(connection, room);

muc.create(userName);

muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));

to:

room="private-chat-" + UUID.randomUUID().toString() + "@groupchat.google.com";
MultiUserChat muc = new MultiUserChat(connection, room);

muc.join(userName);

muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));

And i tried it, but I got new problem- When user recieve invite message and accept it both clients crash with XmlPullException "END_TAG expected" and something like "< /stream:stream>" in last position in logcat.

I started to google this problem and found reason. I used asmack from beem client(by the way, before that i used asmack-7 from asmack developer) and how i know it is based on smack 3.1... I found that smack 3.2.0 decided this problem. I downloaded the Flow's version of asmack and I am pleased with this.

In conclusion I want to say "Thank you!!!" to Flow for correct version of aSmack, which works better than others.

like image 164
nizhney Avatar answered Oct 12 '22 02:10

nizhney


that is Not because of your Client, and thats Not an Error, Thats Because Your Server's GroupChat's History Settings Configured to Send particular Number of Chat History Upon Entering The Room

like image 42
dasdas Avatar answered Oct 12 '22 00:10

dasdas