Subject: Matrix Xmpp: Xamarin Forms issue while sending message or closing connection
I am implementing chat functionality in a Xamarin forms application. Connection to the chat server, user subscription, presence subscription and even message receiving is working smoothly. But while trying to send a message or disconnect a connection, the method execution stuck and it won't be successful. Once a message is received (Sending from Gajim windows client) the execution continues from xmppClient.Send()/xmppClient.Close() calls. I tried it from both Android and iOS applications and the behavior is the same. I also tested the sample app (https://gitlab.com/matrix-xmpp/samples/-/tree/master/cshar…) and its the same behavior, method execution stuck in xmppClient.Close() and only executes further once a message is received.
I am having latest xamarin SDKs
Xamarin iOS - 13.18.3.2
Xamarin Android - 10.3.1.4
Another thing I noticed is that the same code I written works when building from another machine which is having lower version of Xamarin iOS SDK, sending message was working fine. But having issues to send message from Android app which is built from that machine. The Xamarin iOS SDK version in that machine is
Xamarin iOS - 13.6.0.12
Is there any compatibility issue with latest Xamarin SDKs? Please advise how to resolve this issue.
Below are the logs.
PS: OnSendMessage it would log as sending message, but it would get delivered and method execution continues only when a message is received in my app.
I am having latest xamarin SDKs
Xamarin iOS - 13.18.3.2
Xamarin Android - 10.3.1.4
Another thing I noticed is that the same code I written works when building from another machine which is having lower version of Xamarin iOS SDK, sending message was working fine. But having issues to send message from Android app which is built from that machine. The Xamarin iOS SDK version in that machine is
Xamarin iOS - 13.6.0.12
Is there any compatibility issue with latest Xamarin SDKs? Please advise how to resolve this issue.
Below are the logs.
PS: OnSendMessage it would log as sending message, but it would get delivered and method execution continues only when a message is received in my app.
14:35:45.844 D/ChatService: XmppOnSendMessage:<stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="server.address.com" version="1.0" >:
14:35:46.142 D/ChatService: XmppOnXmlReceiveMessage:<stream:stream xmlns:stream="http://etherx.jabber.org/streams" id="5041239102440826853" version="1.0" xml:lang="en" from="server.address.com" xmlns="jabber:client" >:
14:35:46.157 D/ChatService: XmppOnXmlReceiveMessage:<stream:features xmlns:stream="http://etherx.jabber.org/streams">
14:35:46.157 D/ChatService: <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls">
14:35:46.157 D/ChatService: <required />
14:35:46.157 D/ChatService: </starttls>
14:35:46.157 D/ChatService: </stream:features>:
14:35:46.167 D/ChatService: XmppOnSendMessage:<starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" />:
14:35:46.428 D/ChatService: XmppOnXmlReceiveMessage:<proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls" />:
14:35:47.268 D/ChatService: XmppOnSendMessage:<stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="server.address.com" version="1.0" >:
14:35:47.547 D/ChatService: XmppOnXmlReceiveMessage:<stream:stream xmlns:stream="http://etherx.jabber.org/streams" id="18057076616736662190" version="1.0" xml:lang="en" from="server.address.com" xmlns="jabber:client" >:
14:35:47.550 D/ChatService: XmppOnXmlReceiveMessage:<stream:features xmlns:stream="http://etherx.jabber.org/streams">
14:35:47.550 D/ChatService: <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
14:35:47.550 D/ChatService: <mechanism>DIGEST-MD5</mechanism>
14:35:47.550 D/ChatService: <mechanism>PLAIN</mechanism>
14:35:47.550 D/ChatService: <mechanism>SCRAM-SHA-1</mechanism>
14:35:47.550 D/ChatService: <mechanism>X-OAUTH2</mechanism>
14:35:47.550 D/ChatService: </mechanisms>
14:35:47.550 D/ChatService: <register xmlns="http://jabber.org/features/iq-register" />
14:35:47.550 D/ChatService: </stream:features>:
14:35:47.550 D/ChatService: XmppOnStreamFeatures: <stream:features xmlns:stream="http://etherx.jabber.org/streams">
14:35:47.550 D/ChatService: <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
14:35:47.550 D/ChatService: <mechanism>DIGEST-MD5</mechanism>
14:35:47.550 D/ChatService: <mechanism>PLAIN</mechanism>
14:35:47.550 D/ChatService: <mechanism>SCRAM-SHA-1</mechanism>
14:35:47.550 D/ChatService: <mechanism>X-OAUTH2</mechanism>
14:35:47.550 D/ChatService: </mechanisms>
14:35:47.550 D/ChatService: <register xmlns="http://jabber.org/features/iq-register" />
14:35:47.550 D/ChatService: </stream:features>
14:35:47.572 D/ChatService: XmppOnSendMessage:<auth mechanism="PLAIN" xmlns="urn:ietf:params:xml:ns:xmpp-sasl">XXXXX</auth>:
14:35:47.837 D/ChatService: XmppOnXmlReceiveMessage:<success xmlns="urn:ietf:params:xml:ns:xmpp-sasl" />:
14:35:47.843 D/ChatService: xmppClient_OnLogin: Matrix.EventArgs
14:35:47.844 D/ChatService: XmppOnSendMessage:<stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="server.address.com" version="1.0" >:
14:35:48.107 D/ChatService: XmppOnXmlReceiveMessage:<stream:stream xmlns:stream="http://etherx.jabber.org/streams" id="8809054255882851270" version="1.0" xml:lang="en" from="server.address.com" xmlns="jabber:client" >:
14:35:48.112 D/ChatService: XmppOnXmlReceiveMessage:<stream:features xmlns:stream="http://etherx.jabber.org/streams">
14:35:48.112 D/ChatService: <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind" />
14:35:48.112 D/ChatService: <session xmlns="urn:ietf:params:xml:ns:xmpp-session">
14:35:48.112 D/ChatService: <optional />
14:35:48.112 D/ChatService: </session>
14:35:48.112 D/ChatService: <c ver="NqMDrgCx03HLh3URMusgDnNsR30=" node="http://www.process-one.net/en/ejabberd/" hash="sha-1" xmlns="http://jabber.org/protocol/caps" />
14:35:48.112 D/ChatService: <sm xmlns="urn:xmpp:sm:2" />
14:35:48.112 D/ChatService: <sm xmlns="urn:xmpp:sm:3" />
14:35:48.112 D/ChatService: <ver xmlns="urn:xmpp:features:rosterver" />
14:35:48.112 D/ChatService: <csi xmlns="urn:xmpp:csi:0" />
14:35:48.112 D/ChatService: </stream:features>:
14:35:48.127 D/ChatService: XmppOnSendMessage:<iq id="MX_1" type="set" xmlns="jabber:client">
14:35:48.127 D/ChatService: <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">
14:35:48.127 D/ChatService: <resource>MatriX-for-Android</resource>
14:35:48.127 D/ChatService: </bind>
14:35:48.127 D/ChatService: </iq>:
14:35:48.397 D/ChatService: XmppOnXmlReceiveMessage:<iq type="result" id="MX_1" xmlns="jabber:client">
14:35:48.397 D/ChatService: <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">
14:35:48.397 D/ChatService: <jid>jack@server.address.com/MatriX-for-Android</jid>
14:35:48.397 D/ChatService: </bind>
14:35:48.397 D/ChatService: </iq>:
14:35:48.411 D/ChatService: XmppOnSendMessage:<iq to="server.address.com" type="set" id="sess_1">
14:35:48.411 D/ChatService: <session xmlns="urn:ietf:params:xml:ns:xmpp-session" />
14:35:48.411 D/ChatService: </iq>:
14:35:48.415 D/ChatService: XmppOnSendMessage:<enable resume="true" xmlns="urn:xmpp:sm:3" />:
14:35:48.423 D/ChatService: XmppOnSendMessage:<iq id="MX_2" type="get" xmlns="jabber:client">
14:35:48.423 D/ChatService: <query xmlns="jabber:iq:roster" />
14:35:48.423 D/ChatService: </iq>:
14:35:48.670 D/ChatService: XmppOnXmlReceiveMessage:<iq xml:lang="en" to="jack@server.address.com/MatriX-for-Android" from="server.address.com" type="result" id="sess_1" xmlns="jabber:client" />:
14:35:48.670 D/ChatService: <<<<<Session established>>>>>
14:35:48.673 D/ChatService: XmppOnSendMessage:<presence type="subscribe" to="harry@server.address.com" id="MX_3" xmlns="jabber:client" />:
14:35:48.673 D/ChatService: SubscribeUser sent:harry@server.address.com
14:35:48.675 D/ChatService: XmppOnXmlReceiveMessage:<enabled resume="true" max="300" id="g2gCbQAAABJNYXRyaVgtZm9yLUFuZHJvaWRoA2IAAAY7YgAI365iAAABkA==" xmlns="urn:xmpp:sm:3" />:
14:35:48.688 D/ChatService: XmppOnXmlReceiveMessage:<iq xml:lang="en" to="jack@server.address.com/MatriX-for-Android" from="jack@server.address.com" type="result" id="MX_2" xmlns="jabber:client">
14:35:48.688 D/ChatService: <query xmlns="jabber:iq:roster">
14:35:48.688 D/ChatService: <item subscription="both" jid="harry@server.address.com" />
14:35:48.688 D/ChatService: </query>
14:35:48.688 D/ChatService: </iq>:
14:35:48.694 D/ChatService: XmppOnSendMessage:<presence xmlns="jabber:client">
14:35:48.694 D/ChatService: <show>chat</show>
14:35:48.694 D/ChatService: <status></status>
14:35:48.694 D/ChatService: <priority>0</priority>
14:35:48.694 D/ChatService: </presence>:
14:35:48.697 D/ChatService: XmppOnXmlReceiveMessage:<r xmlns="urn:xmpp:sm:3" />:
14:35:48.700 D/ChatService: XmppOnSendMessage:<a h="1" xmlns="urn:xmpp:sm:3" />:
14:35:48.957 D/ChatService: XmppOnXmlReceiveMessage:<presence xml:lang="en" to="jack@server.address.com/MatriX-for-Android" from="jack@server.address.com/MatriX-for-Android" xmlns="jabber:client">
14:35:48.957 D/ChatService: <x xmlns="vcard-temp:x:update" />
14:35:48.957 D/ChatService: <priority>0</priority>
14:35:48.957 D/ChatService: <show>chat</show>
14:35:48.957 D/ChatService: <status />
14:35:48.957 D/ChatService: </presence>:
14:35:48.966 D/ChatService: XmppOnXmlReceiveMessage:<r xmlns="urn:xmpp:sm:3" />:
14:35:48.966 D/ChatService: XmppOnSendMessage:<a h="2" xmlns="urn:xmpp:sm:3" />:
14:35:55.333 D/ChatService: XmppOnSendMessage:<message to="harry@server.address.com" from="jack@server.address.com/MatriX-for-Android" type="chat" id="4b7afe63-3f6c-4191-8270-303e664a6eb7" xml:lang="en" xmlns="jabber:client">
14:35:55.333 D/ChatService: <body>Thank you! I am over it now.</body>
14:35:55.333 D/ChatService: <active xmlns="http://jabber.org/protocol/chatstates" />
14:35:55.333 D/ChatService: <origin-id id="4b7afe63-3f6c-4191-8270-303e664a6eb7" xmlns="urn:xmpp:sid:0" />
14:35:55.333 D/ChatService: </message>:
14:35:46.142 D/ChatService: XmppOnXmlReceiveMessage:<stream:stream xmlns:stream="http://etherx.jabber.org/streams" id="5041239102440826853" version="1.0" xml:lang="en" from="server.address.com" xmlns="jabber:client" >:
14:35:46.157 D/ChatService: XmppOnXmlReceiveMessage:<stream:features xmlns:stream="http://etherx.jabber.org/streams">
14:35:46.157 D/ChatService: <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls">
14:35:46.157 D/ChatService: <required />
14:35:46.157 D/ChatService: </starttls>
14:35:46.157 D/ChatService: </stream:features>:
14:35:46.167 D/ChatService: XmppOnSendMessage:<starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" />:
14:35:46.428 D/ChatService: XmppOnXmlReceiveMessage:<proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls" />:
14:35:47.268 D/ChatService: XmppOnSendMessage:<stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="server.address.com" version="1.0" >:
14:35:47.547 D/ChatService: XmppOnXmlReceiveMessage:<stream:stream xmlns:stream="http://etherx.jabber.org/streams" id="18057076616736662190" version="1.0" xml:lang="en" from="server.address.com" xmlns="jabber:client" >:
14:35:47.550 D/ChatService: XmppOnXmlReceiveMessage:<stream:features xmlns:stream="http://etherx.jabber.org/streams">
14:35:47.550 D/ChatService: <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
14:35:47.550 D/ChatService: <mechanism>DIGEST-MD5</mechanism>
14:35:47.550 D/ChatService: <mechanism>PLAIN</mechanism>
14:35:47.550 D/ChatService: <mechanism>SCRAM-SHA-1</mechanism>
14:35:47.550 D/ChatService: <mechanism>X-OAUTH2</mechanism>
14:35:47.550 D/ChatService: </mechanisms>
14:35:47.550 D/ChatService: <register xmlns="http://jabber.org/features/iq-register" />
14:35:47.550 D/ChatService: </stream:features>:
14:35:47.550 D/ChatService: XmppOnStreamFeatures: <stream:features xmlns:stream="http://etherx.jabber.org/streams">
14:35:47.550 D/ChatService: <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
14:35:47.550 D/ChatService: <mechanism>DIGEST-MD5</mechanism>
14:35:47.550 D/ChatService: <mechanism>PLAIN</mechanism>
14:35:47.550 D/ChatService: <mechanism>SCRAM-SHA-1</mechanism>
14:35:47.550 D/ChatService: <mechanism>X-OAUTH2</mechanism>
14:35:47.550 D/ChatService: </mechanisms>
14:35:47.550 D/ChatService: <register xmlns="http://jabber.org/features/iq-register" />
14:35:47.550 D/ChatService: </stream:features>
14:35:47.572 D/ChatService: XmppOnSendMessage:<auth mechanism="PLAIN" xmlns="urn:ietf:params:xml:ns:xmpp-sasl">XXXXX</auth>:
14:35:47.837 D/ChatService: XmppOnXmlReceiveMessage:<success xmlns="urn:ietf:params:xml:ns:xmpp-sasl" />:
14:35:47.843 D/ChatService: xmppClient_OnLogin: Matrix.EventArgs
14:35:47.844 D/ChatService: XmppOnSendMessage:<stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="server.address.com" version="1.0" >:
14:35:48.107 D/ChatService: XmppOnXmlReceiveMessage:<stream:stream xmlns:stream="http://etherx.jabber.org/streams" id="8809054255882851270" version="1.0" xml:lang="en" from="server.address.com" xmlns="jabber:client" >:
14:35:48.112 D/ChatService: XmppOnXmlReceiveMessage:<stream:features xmlns:stream="http://etherx.jabber.org/streams">
14:35:48.112 D/ChatService: <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind" />
14:35:48.112 D/ChatService: <session xmlns="urn:ietf:params:xml:ns:xmpp-session">
14:35:48.112 D/ChatService: <optional />
14:35:48.112 D/ChatService: </session>
14:35:48.112 D/ChatService: <c ver="NqMDrgCx03HLh3URMusgDnNsR30=" node="http://www.process-one.net/en/ejabberd/" hash="sha-1" xmlns="http://jabber.org/protocol/caps" />
14:35:48.112 D/ChatService: <sm xmlns="urn:xmpp:sm:2" />
14:35:48.112 D/ChatService: <sm xmlns="urn:xmpp:sm:3" />
14:35:48.112 D/ChatService: <ver xmlns="urn:xmpp:features:rosterver" />
14:35:48.112 D/ChatService: <csi xmlns="urn:xmpp:csi:0" />
14:35:48.112 D/ChatService: </stream:features>:
14:35:48.127 D/ChatService: XmppOnSendMessage:<iq id="MX_1" type="set" xmlns="jabber:client">
14:35:48.127 D/ChatService: <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">
14:35:48.127 D/ChatService: <resource>MatriX-for-Android</resource>
14:35:48.127 D/ChatService: </bind>
14:35:48.127 D/ChatService: </iq>:
14:35:48.397 D/ChatService: XmppOnXmlReceiveMessage:<iq type="result" id="MX_1" xmlns="jabber:client">
14:35:48.397 D/ChatService: <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">
14:35:48.397 D/ChatService: <jid>jack@server.address.com/MatriX-for-Android</jid>
14:35:48.397 D/ChatService: </bind>
14:35:48.397 D/ChatService: </iq>:
14:35:48.411 D/ChatService: XmppOnSendMessage:<iq to="server.address.com" type="set" id="sess_1">
14:35:48.411 D/ChatService: <session xmlns="urn:ietf:params:xml:ns:xmpp-session" />
14:35:48.411 D/ChatService: </iq>:
14:35:48.415 D/ChatService: XmppOnSendMessage:<enable resume="true" xmlns="urn:xmpp:sm:3" />:
14:35:48.423 D/ChatService: XmppOnSendMessage:<iq id="MX_2" type="get" xmlns="jabber:client">
14:35:48.423 D/ChatService: <query xmlns="jabber:iq:roster" />
14:35:48.423 D/ChatService: </iq>:
14:35:48.670 D/ChatService: XmppOnXmlReceiveMessage:<iq xml:lang="en" to="jack@server.address.com/MatriX-for-Android" from="server.address.com" type="result" id="sess_1" xmlns="jabber:client" />:
14:35:48.670 D/ChatService: <<<<<Session established>>>>>
14:35:48.673 D/ChatService: XmppOnSendMessage:<presence type="subscribe" to="harry@server.address.com" id="MX_3" xmlns="jabber:client" />:
14:35:48.673 D/ChatService: SubscribeUser sent:harry@server.address.com
14:35:48.675 D/ChatService: XmppOnXmlReceiveMessage:<enabled resume="true" max="300" id="g2gCbQAAABJNYXRyaVgtZm9yLUFuZHJvaWRoA2IAAAY7YgAI365iAAABkA==" xmlns="urn:xmpp:sm:3" />:
14:35:48.688 D/ChatService: XmppOnXmlReceiveMessage:<iq xml:lang="en" to="jack@server.address.com/MatriX-for-Android" from="jack@server.address.com" type="result" id="MX_2" xmlns="jabber:client">
14:35:48.688 D/ChatService: <query xmlns="jabber:iq:roster">
14:35:48.688 D/ChatService: <item subscription="both" jid="harry@server.address.com" />
14:35:48.688 D/ChatService: </query>
14:35:48.688 D/ChatService: </iq>:
14:35:48.694 D/ChatService: XmppOnSendMessage:<presence xmlns="jabber:client">
14:35:48.694 D/ChatService: <show>chat</show>
14:35:48.694 D/ChatService: <status></status>
14:35:48.694 D/ChatService: <priority>0</priority>
14:35:48.694 D/ChatService: </presence>:
14:35:48.697 D/ChatService: XmppOnXmlReceiveMessage:<r xmlns="urn:xmpp:sm:3" />:
14:35:48.700 D/ChatService: XmppOnSendMessage:<a h="1" xmlns="urn:xmpp:sm:3" />:
14:35:48.957 D/ChatService: XmppOnXmlReceiveMessage:<presence xml:lang="en" to="jack@server.address.com/MatriX-for-Android" from="jack@server.address.com/MatriX-for-Android" xmlns="jabber:client">
14:35:48.957 D/ChatService: <x xmlns="vcard-temp:x:update" />
14:35:48.957 D/ChatService: <priority>0</priority>
14:35:48.957 D/ChatService: <show>chat</show>
14:35:48.957 D/ChatService: <status />
14:35:48.957 D/ChatService: </presence>:
14:35:48.966 D/ChatService: XmppOnXmlReceiveMessage:<r xmlns="urn:xmpp:sm:3" />:
14:35:48.966 D/ChatService: XmppOnSendMessage:<a h="2" xmlns="urn:xmpp:sm:3" />:
14:35:55.333 D/ChatService: XmppOnSendMessage:<message to="harry@server.address.com" from="jack@server.address.com/MatriX-for-Android" type="chat" id="4b7afe63-3f6c-4191-8270-303e664a6eb7" xml:lang="en" xmlns="jabber:client">
14:35:55.333 D/ChatService: <body>Thank you! I am over it now.</body>
14:35:55.333 D/ChatService: <active xmlns="http://jabber.org/protocol/chatstates" />
14:35:55.333 D/ChatService: <origin-id id="4b7afe63-3f6c-4191-8270-303e664a6eb7" xmlns="urn:xmpp:sid:0" />
14:35:55.333 D/ChatService: </message>:
This post was edited 2 times, last on 2020-07-30, 23:35 by Alex.