We are facing performance degradation in iOS mobile app, which uses XMPPFramework
So literally after authentication we have 2 screens: (list of chats, and if chat from list is pressed - just real chat ).
After user authorised we starts chats’s sync process. During sync process if I open any chat and trying to send some message or if I am at top of the chart and retrieve previous history page from archive then such requests are executed for a long time.
If syntonisation has finished the requests in such case execute in a short period of time. But if there are some “scheduled” requests (IQs) for XMPP then on chat screen there is a big gap in receiving previous pages from MAM, or sending messages to the XMPP server.
Not sure what causes XMPP’s slow responsiveness: seems that XMPP executes sequentially requests from input stream.
How can we accelerate XMPP’s responsiveness in such case? Kind of request priority is needed :)
If number of chats is low (less than 10), then we don't see big delay, but if # is around 50 then we observe described above issue.
Should we use extra stream, when an user opens chat? Can it be easily done? Stream authorisation can't be eliminated if I am not mistaken.
Technical details:
Stream has the following Info:
<stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" id="5454829587182882369" version="1.0" stream1:lang="en" from="xx.com"/>
RECV:
<stream:features xmlns:stream="http://etherx.jabber.org/streams">
<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/>
<session xmlns="urn:ietf:params:xml:ns:xmpp-session">
<optional/>
</session>
<c xmlns="http://jabber.org/protocol/caps" ver="Sd=" node="http://www.process-one.net/en/ejabberd/" hash="sha-1"/>
<sm xmlns="urn:xmpp:sm:2"/>
<sm xmlns="urn:xmpp:sm:3"/>
<csi xmlns="urn:xmpp:csi:0"/>
</stream:features>
Session’s configuration: (2 duration minutes, keepAlive - 120 seconds)
<iq type="set" id="302D4903-9EA7-4AF1-A070-0362B18D69BE">
<push xmlns="p1:push" apns-sandbox="true">
<appid>xxt</appid>
<keepalive max="120"/>
<session duration="2"/>
<body send="all" groupchat="true" from="none"/>
<status type="xa">Text Message when in push mode</status>
<offline>true</offline>
<notification>
<type>applepush</type>
<id>fafa</id>
</notification>
</push>
</iq>
Sync process:
From our backend we get list of conversations, & contacts. For each chat if it’s MUC we subscribe to it (muc PubSub).
<iq type="set" to="[email protected]" id="BFA024EB-0291-4207-84CC-BD3469568FFE">
<subscribe xmlns="urn:xmpp:mucsub:0" nick="[email protected]">
<event node="urn:xmpp:mucsub:nodes:messages"/>
</subscribe>
</iq>
To get the latest message for each chat we retrieve the latest message from MAM (archive):
<iq type="set" id="6EEB490A-D421-4007-9DA8-E9D2E54DC268" to="[email protected]">
<query xmlns="urn:xmpp:mam:2" queryid="15E9F8CC-1FBE-4DCD-982C-8440E0597BFF">
<x xmlns="jabber:x:data" type="submit">
<field var="FORM_TYPE" type="hidden">
<value>urn:xmpp:mam:2</value>
</field>
</x>
<set xmlns="http://jabber.org/protocol/rsm">
<max>1</max>
<before/>
</set>
</query>
</iq>
After messages are received we store them to our local DBs. We are tracking status of message (sent, read and so on), by using chart markers. Also there is a small number of Group Rosters’ subscription - it shouldn’t be critical point…
Apparently, we use different threads for processing, we don’t block UI (main) thread.
Any ideas?
P.S. attempt to establish extra stream on selected chat led to the following error (RECV):
<stream:error xmlns:stream="http://etherx.jabber.org/streams">
<conflict xmlns="urn:ietf:params:xml:ns:xmpp-streams" />
<text xmlns="urn:ietf:params:xml:ns:xmpp-streams" lang="en">Replaced by new connection</text>
</stream:error>
But this because of server configuration (in-order processing) https://xmpp.org/rfcs/rfc6120.html#rules-order
Default port is 5222 for TCP connection, seems that extra port should be enabled.