Subject: agsXMPP Disconnects from XMPP after a few minutes
I'm connecting to an XMPP server in the following fashion:
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.
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();
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.