Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
rksprst #1
Member since Oct 2010 · 8 posts
Group memberships: Members
Show profile · Link to this post
Subject: agsXMPP Disconnects from XMPP after a few minutes
I'm connecting to an XMPP server in the following fashion:

XmppClientConnection xmpp = new XmppClientConnection("xmpp.site.com");
            xmpp.AutoResolveConnectServer = true;
            xmpp.UseSSL = false;
            xmpp.UseStartTLS = false;
            xmpp.OnReadXml += new XmlHandler(xmpp_OnReadXml);
            xmpp.OnWriteXml += new XmlHandler(xmpp_OnWriteXml);
            xmpp.OnSaslStart += new SaslEventHandler(xmpp_OnSaslStart);
            xmpp.OnMessage += new agsXMPP.protocol.client.MessageHandler(xmpp_OnMessage);
            xmpp.OnXmppConnectionStateChanged += new XmppConnectionStateHandler(xmpp_OnXmppConnectionStateChanged);
            xmpp.OnError += new ErrorHandler(xmpp_OnError);
            xmpp.OnIq += new agsXMPP.protocol.client.IqHandler(xmpp_OnIq);
            xmpp.OnClose += new ObjectHandler(xmpp_OnClose);
            xmpp.AutoRoster = false;
            xmpp.AutoAgents = false;
            xmpp.AutoPresence = false;
            xmpp.KeepAlive = true;
            //xmpp.KeepAliveInterval = 120000;

            xmpp.OnLogin += delegate(object o)
            {
                using (Library.Model.SocialModelDataContext db = new Library.Model.SocialModelDataContext(connectionString))
                {
                    Dictionary<string, int> list = new Dictionary<string, int>();
                    var searches = (from a in db.Searches
                                   select a).ToList();
                    foreach (var search in searches)
                    {
                        if (list.Where(a => a.Key == search.Term).Count() == 0)
                        {
                            list.Add(search.Term, search.SearchGuid);
                        }
                    }
                   
                    foreach (var search in list)
                    {
                        xmpp.Send("<iq type='set' id='subscribe" + search.Value + "' to='search.site.com'><pubsub xmlns='http://jabber.org/protocol/pubsub'>" +
                        "<subscribe jid='" + xmpp.MyJID + "' node='search'/>" +
                        "<options>" +
                        "<x xmlns='jabber:x:data' type='submit'>" +
                        "<field var='FORM_TYPE' type='hidden'>" +
                        "<value>http://jabber.org/protocol/pubsub#subscribe_options</value>" +
                        "</field>" +
                        "<field var='x-collecta#apikey'>" +
                        "<value>" + apiKey + "</value>" +
                        "</field>" +
                        "<field var='x-collecta#query'>" +
                        "<value>" + HttpUtility.HtmlEncode(search.Key) + "</value>" +
                        "</field>" +
                        "</x></options>" +
                        "</pubsub></iq>");
                    }
                    //xmpp.Send(temp);
                }

            };
            xmpp.Open();

I'm also using SASL anonymous. The issue I'm having is that I connect and subscribe to a bunch of requests, get iqs back with confirmation and start receiving data. After a few minutes it randomly disconnects. It's shouldn't be a problem with the xmpp server as they have a ton of other users connecting via xmpp with no issues.

I've tried to run this on different machines (including a few servers with excellent bandwidth connections) thinking it has to do with the bandwidth, but after 1-3 minutes the connection always disconnects.

I've tried setting break points in the library to see where it disconnects, but I can't seem to find any issues.

Any ideas on what is happening or suggestions on debugging it?

I would put the XML output here, but it's not really that helpful - but will do so if you want. Everything is normal until the connection state gets a Disconnect - and then the Disconnect() get's hit in the client socket file.
Avatar
Alex #2
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
when a server disconnects you then there normally is an error message with a reason. So the Xml log helps.

Alex
Avatar
rksprst #3
Member since Oct 2010 · 8 posts
Group memberships: Members
Show profile · Link to this post
I didn't see an error message in the XML log. But here is the last part of it:
xmpp_OnReadXml
<message xmlns="jabber:client" to="16687577231289848537144034@guest.collecta.com
/agsXMPP" from="search.collecta.com">
       <event xmlns="http://jabber.org/protocol/pubsub#event">
        <items node="search"><item id="509CF32BE753D2CE137039C"><entry xmlns="ht
tp://www.w3.org/2005/Atom"><score xmlns="http://api.collecta.com/ns/search-0#res
ults">0.0</score><timesaved xmlns="http://api.collecta.com/ns/search-0#results">
1289848683937</timesaved><language xmlns="http://api.collecta.com/ns/search-0#re
sults">en</language><content xml:base="http://tagn.wordpress.com/2010/11/15/x-53
-touuring-rocker-mounts/#comment-54721" type="html">Heh, I was going to try to m
ake a Turing test joke out of this, given the title "Touuring/Turing," but decid
ed that the true comedy was in the the email itself. </content><title>Comment on
 X-53 Touuring Rocker Mounts by Wilhelm2451</title><link rel="alternate" type="t
ext/html" href="http://tagn.wordpress.com/2010/11/15/x-53-touuring-rocker-mounts
/#comment-54721" /><published>2010-11-15T19:18:02Z</published><id>http://tagn.wo
rdpress.com/?p=11576#comment-54721</id><updated>2010-11-15T19:18:02Z</updated><c
ategory xmlns="http://api.collecta.com/ns/search-0#results">comment</category><s
ite xmlns="http://api.collecta.com/ns/search-0#results">tagn.wordpress.com</site
><abstract xmlns="http://api.collecta.com/ns/search-0#results"><p location="cont
ent">try to make a Turing test joke out of this, given</p><p location="title">Co
mment on X-53 Touuring Rocker</p></abstract></entry></item></items>
      </event>
      <header xmlns="http://jabber.org/protocol/shim">
        <headers name="x-collecta#query">"test"</headers>
        <headers name="subid">509CF2A09272F2CDF16B00</headers>
      </header>
     </message>
xmpp_OnMessage
<message xmlns="jabber:client" to="16687577231289848537144034@guest.collecta.com
/agsXMPP" from="search.collecta.com">
       <event xmlns="http://jabber.org/protocol/pubsub#event">
        <items node="search"><item id="509CF32BE753D2CE137039C"><entry xmlns="ht
tp://www.w3.org/2005/Atom"><score xmlns="http://api.collecta.com/ns/search-0#res
ults">0.0</score><timesaved xmlns="http://api.collecta.com/ns/search-0#results">
1289848683937</timesaved><language xmlns="http://api.collecta.com/ns/search-0#re
sults">en</language><content xml:base="http://tagn.wordpress.com/2010/11/15/x-53
-touuring-rocker-mounts/#comment-54721" type="html">Heh, I was going to try to m
ake a Turing test joke out of this, given the title "Touuring/Turing," but decid
ed that the true comedy was in the the email itself. </content><title>Comment on
 X-53 Touuring Rocker Mounts by Wilhelm2451</title><link rel="alternate" type="t
ext/html" href="http://tagn.wordpress.com/2010/11/15/x-53-touuring-rocker-mounts
/#comment-54721" /><published>2010-11-15T19:18:02Z</published><id>http://tagn.wo
rdpress.com/?p=11576#comment-54721</id><updated>2010-11-15T19:18:02Z</updated><c
ategory xmlns="http://api.collecta.com/ns/search-0#results">comment</category><s
ite xmlns="http://api.collecta.com/ns/search-0#results">tagn.wordpress.com</site
><abstract xmlns="http://api.collecta.com/ns/search-0#results"><p location="cont
ent">try to make a Turing test joke out of this, given</p><p location="title">Co
mment on X-53 Touuring Rocker</p></abstract></entry></item></items>
      </event>
      <header xmlns="http://jabber.org/protocol/shim">
        <headers name="x-collecta#query">"test"</headers>
        <headers name="subid">509CF2A09272F2CDF16B00</headers>
      </header>
     </message>
xmpp_OnReadXml
<message xmlns="jabber:client" to="16687577231289848537144034@guest.collecta.com
/agsXMPP" from="search.collecta.com">
       <event xmlns="http://jabber.org/protocol/pubsub#event">
        <items node="search"><item id="509CF32C913B52CE30E4B0"><entry xmlns="htt
p://www.w3.org/2005/Atom"><score xmlns="http://api.collecta.com/ns/search-0#resu
lts">0.0</score><timesaved xmlns="http://api.collecta.com/ns/search-0#results">1
289848684455</timesaved><language xmlns="http://api.collecta.com/ns/search-0#res
ults">en</language><id>tag:myspace.com,2009:/activity/120371014/MobilePhotoUploa
d/2272266/46717576</id><author><name>amanda</name><uri>http://www.myspace.com/sw
eetheart979</uri><icon>http://c1.ac-images.myspacecdn.com/images02/123/s_039bffe
37ff84edc9236582e69253878.jpg</icon></author><published>2010-11-15T19:18:03Z</pu
blished><updated>2010-11-15T19:18:03Z</updated><link rel="icon" type="image/gif"
 href="http://x.myspacecdn.com/modules/common/static/img/photo.gif" /><link rel=
"alternate" type="text/html" href="http://viewmorepics.myspace.com/index.cfm?fus
eaction=viewImage&amp;friendID=120371014&amp;albumID=2272266&amp;imageID=4671757
6" /><content type="html"> &lt;div xmlns='http://www.w3.org/1999/xhtml'&gt;&lt;d
iv class='activityBody'&gt;&lt;h5 class='activityHeader'&gt;&lt;a href='http://w
ww.myspace.com/sweetheart979'&gt;amanda&lt;/a&gt; uploaded a photo from a mobile
 phone:&lt;/h5&gt;&lt;div class='activityMedia ActivityTemplateMediaGallery'&gt;
&lt;ul class='activityDetailList'&gt;&lt;li class='activityDetailItem'&gt;&lt;a
href='http://viewmorepics.myspace.com/index.cfm?fuseaction=viewImage&amp;amp;fri
endID=120371014&amp;amp;albumID=2272266&amp;amp;imageID=46717576' class='thumbna
ilLink Photo'&gt;&lt;img src='http://c2.ac-images.myspacecdn.com/images02/122/s_
f4bf694fdbfc4d8586d79e1f6a8f8035.jpg' alt='' border='0' class='thumbnailImage'/&
gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content
><title type="text">amanda uploaded a photo from a mobile phone:</title><categor
y xmlns="http://api.collecta.com/ns/search-0#results">photo</category><site xmln
s="http://api.collecta.com/ns/search-0#results">viewmorepics.myspace.com</site><
abstract xmlns="http://api.collecta.com/ns/search-0#results"><link rel="collecta
-abstract-image" href="http://c2.ac-images.myspacecdn.com/images02/122/s_f4bf694
fdbfc4d8586d79e1f6a8f8035.jpg" /><p>photo from a mobile phone:</p><p location="c
ontent">photo from a mobile phone:</p></abstract></entry></item></items>
      </event>
      <header xmlns="http://jabber.org/protocol/shim">
        <headers name="x-collecta#query">"mobile"</headers>
        <headers name="subid">509CF2A1667FB2CDF19E40</headers>
      </header>
     </message>
xmpp_OnMessage
<message xmlns="jabber:client" to="16687577231289848537144034@guest.collecta.com
/agsXMPP" from="search.collecta.com">
       <event xmlns="http://jabber.org/protocol/pubsub#event">
        <items node="search"><item id="509CF32C913B52CE30E4B0"><entry xmlns="htt
p://www.w3.org/2005/Atom"><score xmlns="http://api.collecta.com/ns/search-0#resu
lts">0.0</score><timesaved xmlns="http://api.collecta.com/ns/search-0#results">1
289848684455</timesaved><language xmlns="http://api.collecta.com/ns/search-0#res
ults">en</language><id>tag:myspace.com,2009:/activity/120371014/MobilePhotoUploa
d/2272266/46717576</id><author><name>amanda</name><uri>http://www.myspace.com/sw
eetheart979</uri><icon>http://c1.ac-images.myspacecdn.com/images02/123/s_039bffe
37ff84edc9236582e69253878.jpg</icon></author><published>2010-11-15T19:18:03Z</pu
blished><updated>2010-11-15T19:18:03Z</updated><link rel="icon" type="image/gif"
 href="http://x.myspacecdn.com/modules/common/static/img/photo.gif" /><link rel=
"alternate" type="text/html" href="http://viewmorepics.myspace.com/index.cfm?fus
eaction=viewImage&amp;friendID=120371014&amp;albumID=2272266&amp;imageID=4671757
6" /><content type="html"> &lt;div xmlns='http://www.w3.org/1999/xhtml'&gt;&lt;d
iv class='activityBody'&gt;&lt;h5 class='activityHeader'&gt;&lt;a href='http://w
ww.myspace.com/sweetheart979'&gt;amanda&lt;/a&gt; uploaded a photo from a mobile
 phone:&lt;/h5&gt;&lt;div class='activityMedia ActivityTemplateMediaGallery'&gt;
&lt;ul class='activityDetailList'&gt;&lt;li class='activityDetailItem'&gt;&lt;a
href='http://viewmorepics.myspace.com/index.cfm?fuseaction=viewImage&amp;amp;fri
endID=120371014&amp;amp;albumID=2272266&amp;amp;imageID=46717576' class='thumbna
ilLink Photo'&gt;&lt;img src='http://c2.ac-images.myspacecdn.com/images02/122/s_
f4bf694fdbfc4d8586d79e1f6a8f8035.jpg' alt='' border='0' class='thumbnailImage'/&
gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content
><title type="text">amanda uploaded a photo from a mobile phone:</title><categor
y xmlns="http://api.collecta.com/ns/search-0#results">photo</category><site xmln
s="http://api.collecta.com/ns/search-0#results">viewmorepics.myspace.com</site><
abstract xmlns="http://api.collecta.com/ns/search-0#results"><link rel="collecta
-abstract-image" href="http://c2.ac-images.myspacecdn.com/images02/122/s_f4bf694
fdbfc4d8586d79e1f6a8f8035.jpg" /><p>photo from a mobile phone:</p><p location="c
ontent">photo from a mobile phone:</p></abstract></entry></item></items>
      </event>
      <header xmlns="http://jabber.org/protocol/shim">
        <headers name="x-collecta#query">"mobile"</headers>
        <headers name="subid">509CF2A1667FB2CDF19E40</headers>
      </header>
     </message>
Disconnected
agsXMPP.XmppClientConnection

There's not really an error message - it just disconnects.
Avatar
Alex #4
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by rksprst:
There's not really an error message - it just disconnects.
When there is no problem in your code which causes an exception and a disconnect then there must be something on the Collecta XMPP server which disconnects you. Can you try to contact the developers?

Have you tried to use the Collecta API from another XMPP server over s2s? But be aware that you have to remove the pubsub subscriptions on your own when you don't connect anonymous to the Collecta search.

Alex
Avatar
rksprst #5
Member since Oct 2010 · 8 posts
Group memberships: Members
Show profile · Link to this post
Yes, I've been in contact with them. They say they have other users connecting this way so they are highly skeptical that this is something on their side.

I haven't tried connecting via s2s, are there any .net libraries that are able to do so? Is agsXMPP able to do a s2s connection? All I could find were python ones.
Avatar
Alex #6
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by rksprst:
Yes, I've been in contact with them. They say they have other users connecting this way so they are highly skeptical that this is something on their side.

same here, so this does not help ;-)
I have attached a Collecta example for MatriX. Can you try if you have the same problem with MatriX?

Quote by rksprst:
I haven't tried connecting via s2s, are there any .net libraries that are able to do so? Is agsXMPP able to do a s2s connection? All I could find were python ones.

with s2s I meant that you login to another public XMPP server, eg. jabber.org. Then jabber.org delivers your packets over s2s to search.collecta.com. You don't need any s2s code for that.

Alex
The author has attached one file to this post:
Collecta.zip 13.6 kBytes
You have no permission to open this file.
Avatar
Alex #7
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #1
Quote by rksprst on 2010-11-15, 20:32:
1289849578

can you try to debug the disconnect and see n the call stack where its coming from?

Alex
Avatar
rksprst #8
Member since Oct 2010 · 8 posts
Group memberships: Members
Show profile · Link to this post
The call stack just has this:
>    agsXMPP.dll!agsXMPP.net.ClientSocket.EndReceive(System.IAsyncResult ar = {System.Net.Sockets.OverlappedAsyncResult}) Line 646    C#

The Disconnect() gets hit in line 646 of ClientSocket() - here's the location:
nBytes = m_NetworkStream.EndRead(ar);
                if( nBytes > 0 )
                {
                    // uncompress Data if we are on a compressed socket
                    if (m_Compressed)
                    {                       
                        byte[] buf = Decompress(m_ReadBuffer, nBytes);
                        base.FireOnReceive(buf, buf.Length);
                        // for compression debug statistics
                        //base.FireOnInComingCompressionDebug(this, m_ReadBuffer, nBytes, buf, buf.Length);
                    }
                    else
                    {
                        //Console.WriteLine("Socket OnReceive: " + System.Text.Encoding.UTF8.GetString(m_ReadBuffer, 0, nBytes));                       
                        // Raise the receive event
                        base.FireOnReceive(m_ReadBuffer, nBytes);
                    }
                    // Setup next Receive Callback
                    if (this.Connected)
                        this.Receive();
                }
                else
                {
                    Disconnect(); //<----- THIS IS WHERE IT DISCONNECTS
                }

Maybe it has to do with the OverlappedAsyncResult issue. I'm also getting disconnected with the sample project you posted.
Avatar
Alex #9
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by rksprst:
...
else
{
   Disconnect(); //<----- THIS IS WHERE IT DISCONNECTS
}
...
this is a "normal" disconnect caused by the server.

Quote by rksprst:
Maybe it has to do with the OverlappedAsyncResult issue. I'm also getting disconnected with the sample project you posted.
I never heard from an OverlappedAsyncResult issue. Can you elaborate?

Alex
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS