1
votes

I'm using Alamofire to download multiple files at once from different servers.

I have an array of files, and for each of them i store the respective Alamofire.Request like so:

class SampleFile {
    var filename : String = ""
    var request : Alamofire.Request? = nil
}

and

var array : [SampleFile] = []

This array populates a UITableView, and when a button inside a cell is pressed, i assign the request like this:

func startDownload(row: Int) {
    array[row].request =  Manager.sharedInstance.download(.GET, someUrl, destination: someDestination)
} 

I also have a function to stop the request in this way:

func stopDownload(row: Int) {
    array[row].request!.cancel()
    array[row].request = nil
}

Now everything seems to work fine, even multiple downloads at once.

However, when i stop a specific download from a certain server, say example.com, then every other ongoing download from example.com server will be stopped too at the same time (with error: "The network connection was lost"), while downloads from other servers are not affected.

Is this normal behaviour? Is there any way to keep other connections from that server alive while cancelling only one?

1

1 Answers

1
votes

Never mind, it was a server issue. Reconfigured it and everything is working.