ConnectFailure error causes app to cease connecting externally

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

ConnectFailure error causes app to cease connecting externally

bamagrad03
I've got an app that does a number of externally focused things: twitter via oAuth, connecting to my web server services, etc. And everything works great, but after about 3-4 minutes of heavy use, the app starts throwing:

Error: ConnectFailure (System call failed)

More specifically:

  at System.Net.HttpWebRequest.EndGetRequestStream (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
  at System.Net.HttpWebRequest.GetRequestStream () [0x00000] in <filename unknown>:0
  at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke (System.String method_name, System.Object[] parameters) [0x00000] in <filename unknown>:0

Now, I can trap for this. But the bigger issue is, once I get this error, the app NEVER recovers. It won't connect to my RSS feeds, Twitter oAuth, or any of my webservices. I continue to get the same connectfailure error until I restart the app.

Could this be a case of me not disposing manually of some resource that I should be? Here's some code from my webservice data pull, but keep in mind, this is only one of many ways I connect.

List<BBStandings> rank = new List<BBStandings>();
                        try{
                        var service = new ServiceName.Service();
                       
                        XmlDocument xmlDoc = new XmlDocument();
                        xmlDoc.LoadXml(service.GetStandings());
                       
                        string s = xmlDoc.InnerXml;
                        -- bunch of variables declared
                        int iCount = 1;
                       
                        if (s != "<NewDataSet />")
                        {
                        System.Xml.XmlTextReader xml = new System.Xml.XmlTextReader(new System.IO.StringReader(s));
                        int iXML = 0;
                       
                        while (xml.Read())
                        {
                                switch (xml.NodeType)
                                {
                                        case XmlNodeType.EndElement:
                                                iCount = 1;
                                                sElement = "";
                                                sText = "";
                                                break;
                                        case XmlNodeType.Element:
                                                sElement = xml.Name;
                                                iCount = 2;
                                                break;
                                        case XmlNodeType.Text:
                                                //sElement = xml.Name;
                                                sText = xml.Value;
                                                iCount = 3;
                                                break;
                                }
                                if (iCount == 3)
                                {
                                        switch (sElement)
                                        {
                                        case "TeamID":
                                                sTeamID = sText;
                                                iCount = 1;
                                                break;
                                        case "TeamName":
                                                sTeamName = sText;
                                                iCount = 1;
                                                break;
                                        case "ConferenceRecord":
                                                sConferenceRecord = sText;
                                                iCount = 1;
                                                break;
                                        case "Record":
                                                sRecord = sText;
                                                BBStandings r = new BBStandings();
                                               
                                                r.TeamID = Convert.ToInt32(sTeamID);
                                                r.TeamName = sTeamName;
                                               
                                                r.ConferenceRecord = sConferenceRecord;
                                               
                                                r.Record = sRecord;
                                                 
                                                rank.Insert(iXML, r);
                                               
                                                iXML += 1;
                                                sTeamID = "";
                                                sConferenceRecord = "";
                                       
                                                sTeamName = "";
                                                sRecord = "";
                                                sText = "";
                                                sElement = "";
                                                break;
                                        }
                                }
                        }
                        }
                        }
                        catch (Exception ex)
                        {
                                string s=ex.Message;
                        }
                        return rank;

I'm running MD 2.6.0.1
MonoFramework 2.10.5
MT 4.2.2
Reply | Threaded
Open this post in threaded view
|

Re: ConnectFailure error causes app to cease connecting externally

Rolf Bjarne Kvinge
Hi,

Yeah, my guess would be that you're missing a Close/Dispose somewhere
(but I couldn't find anything missing in the case you showed). I
wouldn't look at the web services first, it's more likely a problem
with the code where you're using sockets and/or http requests
yourself.

Rolf

On Mon, Oct 24, 2011 at 4:49 AM, bamagrad03 <[hidden email]> wrote:

> I've got an app that does a number of externally focused things: twitter via
> oAuth, connecting to my web server services, etc. And everything works
> great, but after about 3-4 minutes of heavy use, the app starts throwing:
>
> Error: ConnectFailure (System call failed)
>
> More specifically:
>
>  at System.Net.HttpWebRequest.EndGetRequestStream (IAsyncResult
> asyncResult) [0x00000] in <filename unknown>:0
>  at System.Net.HttpWebRequest.GetRequestStream () [0x00000] in <filename
> unknown>:0
>  at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke
> (System.String method_name, System.Object[] parameters) [0x00000] in
> <filename unknown>:0
>
> Now, I can trap for this. But the bigger issue is, once I get this error,
> the app NEVER recovers. It won't connect to my RSS feeds, Twitter oAuth, or
> any of my webservices. I continue to get the same connectfailure error until
> I restart the app.
>
> Could this be a case of me not disposing manually of some resource that I
> should be? Here's some code from my webservice data pull, but keep in mind,
> this is only one of many ways I connect.
>
> List<BBStandings> rank = new List<BBStandings>();
>                        try{
>                        var service = new ServiceName.Service();
>
>                        XmlDocument xmlDoc = new XmlDocument();
>                        xmlDoc.LoadXml(service.GetStandings());
>
>                        string s = xmlDoc.InnerXml;
>                        -- bunch of variables declared
>                        int iCount = 1;
>
>                        if (s != "<NewDataSet />")
>                        {
>                        System.Xml.XmlTextReader xml = new System.Xml.XmlTextReader(new
> System.IO.StringReader(s));
>                        int iXML = 0;
>
>                        while (xml.Read())
>                        {
>                                switch (xml.NodeType)
>                                {
>                                        case XmlNodeType.EndElement:
>                                                iCount = 1;
>                                                sElement = "";
>                                                sText = "";
>                                                break;
>                                        case XmlNodeType.Element:
>                                                sElement = xml.Name;
>                                                iCount = 2;
>                                                break;
>                                        case XmlNodeType.Text:
>                                                //sElement = xml.Name;
>                                                sText = xml.Value;
>                                                iCount = 3;
>                                                break;
>                                }
>                                if (iCount == 3)
>                                {
>                                        switch (sElement)
>                                        {
>                                        case "TeamID":
>                                                sTeamID = sText;
>                                                iCount = 1;
>                                                break;
>                                        case "TeamName":
>                                                sTeamName = sText;
>                                                iCount = 1;
>                                                break;
>                                        case "ConferenceRecord":
>                                                sConferenceRecord = sText;
>                                                iCount = 1;
>                                                break;
>                                        case "Record":
>                                                sRecord = sText;
>                                                BBStandings r = new BBStandings();
>
>                                                r.TeamID = Convert.ToInt32(sTeamID);
>                                                r.TeamName = sTeamName;
>
>                                                r.ConferenceRecord = sConferenceRecord;
>
>                                                r.Record = sRecord;
>
>                                                rank.Insert(iXML, r);
>
>                                                iXML += 1;
>                                                sTeamID = "";
>                                                sConferenceRecord = "";
>
>                                                sTeamName = "";
>                                                sRecord = "";
>                                                sText = "";
>                                                sElement = "";
>                                                break;
>                                        }
>                                }
>                        }
>                        }
>                        }
>                        catch (Exception ex)
>                        {
>                                string s=ex.Message;
>                        }
>                        return rank;
>
> I'm running MD 2.6.0.1
> MonoFramework 2.10.5
> MT 4.2.2
>
>
> --
> View this message in context: http://monotouch.2284126.n4.nabble.com/ConnectFailure-error-causes-app-to-cease-connecting-externally-tp3931899p3931899.html
> Sent from the MonoTouch mailing list archive at Nabble.com.
> _______________________________________________
> MonoTouch mailing list
> [hidden email]
> http://lists.ximian.com/mailman/listinfo/monotouch
>
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|

Re: ConnectFailure error causes app to cease connecting externally

pseabury
In reply to this post by bamagrad03
I have the same problem from time to time.  I outlined my case here: http://stackoverflow.com/questions/10217875/monotouch-webservice-fails-after-some-number-of-requests-with-connectfailure-s .

Liek the original poster said, once this happens, the app can never recover...it must be killed and restarted.
Reply | Threaded
Open this post in threaded view
|

Re: ConnectFailure error causes app to cease connecting externally

pseabury
In reply to this post by Rolf Bjarne Kvinge
Hi Rolf -

I'd say that you'd be correct except that it looks like we're both using a basic HttpWebRequest/HttpWebResponse pattern.  Not even using the streams directly, certainly no sockets directly.  One of my users on an iPodTouch seems to be able to reproduce this more often.  Not sure if that is because it's a single CPU device or not.

Anyway, it is a big problem because it leaves the app in a completely unusable state.  

In the linked StackOverflow example (earlier in this thread), I was using a web reference to a WCF service similar to what bamagrad showed.  I'm currently still seeing this after changing the network stack completely to using ServiceStack on both client & server.

Best,

Paul
Reply | Threaded
Open this post in threaded view
|

Re: ConnectFailure error causes app to cease connecting externally

pseabury
In reply to this post by bamagrad03
Reply | Threaded
Open this post in threaded view
|

Re: ConnectFailure error causes app to cease connecting externally

pseabury
Ran across this error again on a new Debug build of my app - I wasn't debugging however.  I was able to plug the device into my Mac and get the XCode console up, which showed the same error happening in a Response somewhere, even though I could verify via proxy that no request was ever being sent in this state:

Aug  3 09:51:50 unknown timed[14438] <Notice>: (Note ) CoreTime: Want active time in 15.59hrs. Need active time in 98.92hrs.
Aug  3 09:51:51 unknown UIKitApplication:com.elantech-inc.imdss[0xf858][14025] <Notice>: Reachability checked premium.staging.imdssonline.com in 70ms
Aug  3 09:51:51 unknown UIKitApplication:com.elantech-inc.imdss[0xf858][14025] <Notice>: DEBUG: Exception Reading Response Error: Error: ConnectFailure (System call failed), Exception: Error: ConnectFailure (System call failed)
Is anyone at Xamarin even interested in looking at this?  Given that its impact is high when it happens, I thought that someone might take a look.  I guess I'll create a bug over at bugzilla without a test case for now.


Paul

On Fri, Aug 3, 2012 at 10:20 AM, pseabury <[hidden email]> wrote:




--
View this message in context: http://monotouch.2284126.n4.nabble.com/ConnectFailure-error-causes-app-to-cease-connecting-externally-tp3931899p4656351.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch


_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|

Re: ConnectFailure error causes app to cease connecting externally

Rolf Bjarne Kvinge
Hi,

Can you create a test case for this (or even the whole app if reproducing it doesn't require constant user interaction)? That is really the only way to figure it out.

Rolf

On Fri, Aug 3, 2012 at 1:42 PM, Paul Seabury <[hidden email]> wrote:
Ran across this error again on a new Debug build of my app - I wasn't debugging however.  I was able to plug the device into my Mac and get the XCode console up, which showed the same error happening in a Response somewhere, even though I could verify via proxy that no request was ever being sent in this state:

Aug  3 09:51:50 unknown timed[14438] <Notice>: (Note ) CoreTime: Want active time in 15.59hrs. Need active time in 98.92hrs.
Aug  3 09:51:51 unknown UIKitApplication:com.elantech-inc.imdss[0xf858][14025] <Notice>: Reachability checked premium.staging.imdssonline.com in 70ms
Aug  3 09:51:51 unknown UIKitApplication:com.elantech-inc.imdss[0xf858][14025] <Notice>: DEBUG: Exception Reading Response Error: Error: ConnectFailure (System call failed), Exception: Error: ConnectFailure (System call failed)
Is anyone at Xamarin even interested in looking at this?  Given that its impact is high when it happens, I thought that someone might take a look.  I guess I'll create a bug over at bugzilla without a test case for now.


Without a test case 
 

Paul

On Fri, Aug 3, 2012 at 10:20 AM, pseabury <[hidden email]> wrote:




--
View this message in context: http://monotouch.2284126.n4.nabble.com/ConnectFailure-error-causes-app-to-cease-connecting-externally-tp3931899p4656351.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch


_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch



_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch