2
votes

I'm creating custom xmpp chat application with use of Strophe.js. The communication between browser and desktop client (Adium) works perfectly. I can send messages via browser to Adium and from Adium to the browser. There is yet the problem with browser-browser communication at some point as messages are sent but not delivered. It seems it's just Google Chrome problem.

What's interesting is the fact that <presence> stanzas are sent and delivered fine. We use ejabberd as the server daemon.

This is the presence stanza I'm sending from one account:

<presence type="away" xmlns="jabber:client">
    <show>away</show>
    <status/>
</presence>

and what I receive on the other:

<presence xmlns="jabber:client" from="[email protected]/3917283126133167196759537" to="[email protected]/1563391996133167110798391" type="away">
    <show>away</show>
    <status/>
</presence>

also the message stanza I send:

<message from="[email protected]/267172122813316722921543" to="[email protected]" type="chat" id="4915" xmlns="jabber:client">
    <active xmlns="http://jabber.org/protocol/chatstates" />
    <body>Testing...</body>
</message>

and nothing is received on Chrome...

EDIT: The problem was with escaping some characters. Chrome did not let them unescaped due to security issues.

1
Could you tell what is the problem with the characters. I am using strophe with punjab. I receive the just the first message, but not the later messages. Messages are sent but nothing is received on Chrome. <message type="chat" id="purple8a0d0124" to="[email protected]" from="[email protected]/9806171F"> <active xmlns="jabber.org/protocol/chatstates"> <body>this is testing..</body> <nos:x value="disabled" xmlns:nos="google:nosave"/> <arc:record otr="false" xmlns:arc="jabber.org/protocol/archive"> </message>Nitish Borade
@NitishBorade are you sure nothing is received? It sounds like the listener function did not return true after the first message.Michał Miszczyszyn

1 Answers

1
votes

The type="away" in your initial presence is not valid. Omit the 'type' attribute for available presence. Set type="unavailable" when you are going offline.

Because your presence is invalid you are not marked as available, and you will not receive any messages addressed to your bare JID.

Update: To clear any confusion about what I mean by the above (see comments)...

The 'type' attribute on this stanza is invalid:

<presence type="away" xmlns="jabber:client">
    <show>away</show>
    <status/>
</presence>

It is otherwise fine. There are two types of presence a client may send, available and unavailable. Standard available presence has no 'type' attribute. Unavailable presence has type="unavailable". The actual status of the user (away, etc.) is signaled via the <show/> and <status/> elements, not the 'type' attribute.

To make it the above stanza a valid available presence, just remove type="away":

<presence xmlns="jabber:client">
    <show>away</show>
    <status/>
</presence>