URLSession dataTask - не удалось подключиться к серверу - PullRequest
0 голосов
/ 07 сентября 2018

Я пытаюсь загрузить данные со следующего URL: https://www.sample -videos.com / video / mp4 / 720 / big_buck_bunny_720p_1mb.mp4

Функция

func download() {
    let configuration = URLSessionConfiguration.default

    self.session = URLSession(configuration: configuration, delegate: self, delegateQueue: nil)
    self.downloadTask = self.session.dataTask(with: self.url)                
    self.downloadTask.resume()
}

1012 * Делегаты *

// NOT GETTING CALLED
func urlSession(_ session: URLSession, task: URLSessionTask, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
    completionHandler(URLSession.AuthChallengeDisposition.useCredential, URLCredential(trust: challenge.protectionSpace.serverTrust!))
}

// NOT GETTING CALLED
func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
    completionHandler(URLSession.AuthChallengeDisposition.useCredential, URLCredential(trust: challenge.protectionSpace.serverTrust!))
}

func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) {
    self.completion(self, data)
}

func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
    print(error)
   // THIS IS GETTING CALLED WITH ERROR: Could not connect to the server. FULL ERROR BELOW.
}

func urlSession(_ session: URLSession, didBecomeInvalidWithError error: Error?) {
    print(error)
}

Полная ошибка

(Ошибка домена = NSURLErrorDomain Code = -1004 \ "Не удалось подключиться к сервер. \ "UserInfo = {NSUnderlyingError = 0x1c0658cc0 {Ошибка Домен = kCFErrorDomainCFNetwork Code = -1004 \ "(null) \" UserInfo = {_ kCFStreamErrorCodeKey = 61, _kCFStreamErrorDomainKey = 1}}, NSErrorFailingURLStringKey = * ** тысяча двадцать одна тысячи двадцать-два * -videos.com / видео / MP4 / 720 / big_buck_bunny_720p_1mb.mp4 , NSErrorFailingURLKey = https://www.sample -videos.com / видео / mp4 / 720 / big_buck_bunny_720p_1mb.mp4 , _kCFStreamErrorDomainKey = 1, _kCFStreamErrorCodeKey = 61, NSLocalizedDescription = Не удалось подключиться к серверу.})

Ниже приведена конфигурация ATS

enter image description here

Любая помощь будет очень признательна!

Примечание Приведенный выше URL работает в Chrome, но не загружается в Safari

...