What does "error in connection_block_invoke_2: connection interrupted" mean?

Problem

I recently updated my iPhone to iOS 10.3.1 and Xcode to 8.3.2. I currently have an application that launches several URLRequest

after my application starts.

However, after updating iOS and Xcode, the app sometimes returns an error:

Error in connection_block_invoke_2: Connection interrupted

The message is rather vague, but I assumed it had something to do URLRequest

with since it mentions "Connection being dropped".

Whenever this error message appears, it will "freeze" the application ~ 5 seconds before receiving data from the server.


Question

So what does this error message mean? And how can I minimize or fix it?


Example of one URLRequest

:

func checkLogin () {
    let username = txtUsername.text!
    let password = txtPassword.text!

    let post = "username=\(username)&password=\(password)"
    NSLog("PostData: %@",post);
    let url:URL = URL(string:"https://example.com/login.php")!
    let postData = post.data(using: .utf8)!
    let postLength = String( postData.count )
    var request = URLRequest(url: url)

    request.httpMethod = "POST"
    request.httpBody = postData
    request.setValue(postLength as String, forHTTPHeaderField: "Content-Length")
    request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
    request.setValue("application/json", forHTTPHeaderField: "Accept")
    let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
        if error != nil {
            return
        }
        if let jsonData = (try? JSONSerialization.jsonObject(with: data!, options: [])) as? [String:Any] {
            let success = jsonData["success"] as! Int
            if success == 1 {
                //do something,
            }
            else {
                //show alert
            }
        }

    })
    task.resume()
}

      


Duplicates

The following questions do not solve my problem:

  • What is "error in __connection_block_invoke_2: connection is interrupted" in iOS?

    • I didn't get a memory save warning, so the answer doesn't apply.
  • iOS: error in __connection_block_invoke_2: connection is interrupted

    • In my application, I have not used AVCaptureMovieFileOutput

      and at all AVCaptureVideoDataOutput

      , so the answer does not apply either.
  • error in __connection_block_invoke_2: connection broken on iPad and Xcode 7 error message "in __connection_block_invoke_2: connection broken" when app is running on iPad

    • No answer at all.
+3
ios xcode swift


source to share


No one has answered this question yet

See similar questions:

12
What is "error in __connection_block_invoke_2: connection is interrupted" in iOS?
nine
iOS: error in __connection_block_invoke_2: connection is interrupted
8
Xcode 7 error message "error in __connection_block_invoke_2: connection is disconnected" when app is launched on iPad
five
error in __connection_block_invoke_2: connection is interrupted on iPad

or similar:

1264
How to check an active internet connection on iOS or macOS?
1132
Xcode - How to fix "NSUnknownKeyException" Reason:… this class does not match the key value encoding the error "X"?
868
Xcode error "Could not find developer disk image"
805
Xcode 7 error: "Missing iOS Distribution Subscription ID for ..."
548
What does the NS prefix mean?
479
What does an exclamation point mean in Swift?
426
What does the "__block" keyword mean?
nine
iOS: error in __connection_block_invoke_2: connection is interrupted
8
Xcode 7 error message "error in __connection_block_invoke_2: connection is disconnected" when app is launched on iPad
1
Error in __connection_block_invoke_2: connection interrupted only on iPad



All Articles
Loading...
X
Show
Funny
Dev
Pics