ConnectFailure (System call failed) causes a need to restart

When this error shows up, periodically, no amount of prodding or restarting can get communication to continue. I have to force a restart on the iPad.
This is in an app that has been using the same communications (WebService SOAP based) for a year without issue. Recently, this error has started showing up every 15 minutes (or so) for people that need to work 8 hours...
I have seen a couple people ask about this, but nobody has an answer yet. Has anyone seen this and what can be done about it?

Best Answer


  • BrettNagyBrettNagy USMember, Beta

    I'm seeing the same error from time to time. I have tried creating a consistently failing test case, but cannot.

    It must say something that if I make HTTP calls in a loop I cannot force the error. If I interact with my app (making HTTP calls), I get this error after just a few minutes.

  • JohnMillerJohnMiller USForum Administrator, Xamarin Team Xamurai


    I get this error if I use my app, but isolating the call that errors in a test app, looping over the HTTP call 10K times, I do not get the error.... I am using SQLite as well. I have not been able to fix this issue, I have just had to reduce my HTTP calls.

    Often this happens because I have a data access method in the ViewDidLoad, or ViewWillAppear, so when I repeatedly push a view controller back and forth, causing that method to fire each time, I get this error.

  • JasonLeachJasonLeach USMember

    I was using SQL Lite. I removed it, and my problem went away...
    Bummer. because the SQL lite stuff was very useful. Perhaps, when it is based on the same version as apple/iOS, it will function a little better.
    For now, I saved my data as flat files and all is well.

  • JohnMillerJohnMiller USForum Administrator, Xamarin Team Xamurai


    Removing your SQL calls 100% fixed this issues? You still are using your SOAP based web calls? Was there some functionality in your code that called SQLite methods, near or at the same time as calling SOAP based methods?

    This error always happens for me (at least from a logging standpoint) on SOAP based web calls, as you stated in your original post.

  • JasonLeachJasonLeach USMember

    I could not dependably recreate this issue in test, with loops or otherwise. Yet it was quick to fail in production. I am 100% cured... have been for a while, but did not post that, as, for a long time no one else seemed to care. I have had 3 or 4 releases of my infected app since taking SQL Lite out and no issues whatsoever. I still use SOAP heavily (and almost exclusively) in this app. I hope you can divest your app from SQL lite without pain. you will find this error goes away. - Jason

  • RolfBjarneKvingeRolfBjarneKvinge USXamarin Team Xamurai

    If you're using SQLite make sure you're not closing connections before their commands.

    This is fairly common code I've seen in several cases:

    using (var cmd = Connection.CreateCommand ()) {
        // use the command
        Connection.Close ();

    Here the connection is closed before the command is disposed. Unfortunately SQLite doesn't tell you anything when this happens, but it will leak file handles (the connection will in fact not be closed), eventually leading to random errors somewhere else (creating a socket might fail for instance).

    Fortunately this is very easy to debug if you just know how: make Xamarin Studio break on all exceptions (or just SqliteException) - open the Run->Exceptions menu and add System.Exception.

    Run your app and it'll break with a stack trace which will tell you exactly where SQLiteConnection.Close is called too early.

    More info:

  • JohnMillerJohnMiller USForum Administrator, Xamarin Team Xamurai
    edited July 2013


    Wow Rolf, thank you so much. I took your advice and I get that exception all over the place. Here is what my culprit code looks like:

    SqliteCommand cmd = SQLdb.createCommand(...);
    using (var reader = cmd.ExecuteReader())
     while (reader.Read())
        // Do some work
    SQLdb.closeCommand(ref cmd);

    What needs to be called on cmd in this case, Dispose()?

    closeCommand() simply does this:

    cmd.Connection.Close ();
  • RolfBjarneKvingeRolfBjarneKvinge USXamarin Team Xamurai

    @John: you need to call cmd.Dispose () before cmd.Connection.Close ().

  • JohnMillerJohnMiller USForum Administrator, Xamarin Team Xamurai


    When I implement that, I seem to get an Object reference null error when calling cmd.Connection.Close().

  • RolfBjarneKvingeRolfBjarneKvinge USXamarin Team Xamurai

    @John: Try storing the Connection locally in the meantime:

    var conn = cmd.Connection;
    cmd.Dispose ();
    conn.Close ();
Sign In or Register to comment.