Содержание
- NSURLErrorDomain error code 1002 description
- 3 Answers 3
- NSURLConnection finished with error — code -1022
- 5 Answers 5
- NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802 in iOS10, 2017
- 3 Answers 3
- NSURLConnection завершилось с ошибкой — код -1002
- 3 ответа
- Похожие вопросы:
NSURLErrorDomain error code 1002 description
I am new to iOS development. I am trying to load a JSON, here’s my function:
But I am getting this error:
The operation couldn’t be completed. (NSURLErrorDomain error -1002.)
I am able to get the JSON in the browser through the same URL. I have tried reading this Apple Doc, but I can’t get the description.
What does this error code mean?
3 Answers 3
NSURLErrorDomain error -1002 means NSURLErrorUnsupportedURL or kCFURLErrorUnsupportedURL . It indicates that a bad URL was provided, in most cases, missing http:// from the URL prefix.
In addition to the above answer, one of the reasons why this could happen is,
You might have set the Allow Arbitrary Loads to false in your Info.plist and the URL you are trying to load is not on a secured server.
The solution to this is either set it to true , or move to a secure connection i.e https:// .
Hope it helps someone. All the best.
I encounter the same issue and found that key parameter was missing from URL. You need to set Google map key value for key parameter in URL you are using to make request. This can be occur if you are missing other keys.
Источник
NSURLConnection finished with error — code -1022
Guys i try to learn webview it can’t load give me error like:
NSURLConnection finished with error — code -1022
5 Answers 5
I think it is about App Transport Security.Because your url is not https.Try to change like this in the info.plist file
You are getting this error because you are not using https url. To fix follow below steps:
- Right click on info.plist file.
- Open As Source code.
Add below line just before /dict:
I was having a similar issue,
I was trying to reach a blocked port in my company. Changing the port let me connect normally.
As pointed out below, disabling Firewall could also solve the issue.
To give an answer on your question we need to see full logs. But I guess the problem in the App Transport Security. Since iOS 9 all connection should be done with https and the destination url should be backed with TLS version greater or equal 1.2, until you’ll not specify exceptions in info.plist file in App Transport security section. Also you can «Allow Arbitrary Loads» for all connections, but this way isn’t preferred. You can read more details about this here https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html (in the NSAppTransportSecurity section)
Few silly things but give a try as below:
First, you can try to check the issue on the simulator i.e run the app in the simulator and check whether still there is an issue.
In-network class or where your API call function check whether this is implemented
request.allHTTPHeaderFields = [«Content-Type» : «application/json»]
Right-click on info.plist file. select open as source code.
check and find below whether lines are present
if not present add above lines just before /dict:
Also, check if you are URL is from the local server and you are switching to the different live URL.
Check the internet connection of the device.
Источник
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802 in iOS10, 2017
THIS IS NOT A REPEATED QUESTION, READ ON. I am upgrading the deprecated code in my app to iOS10 compliance.
THE ERROR: NSURLSession is giving me trouble, with this infamous error, along with 9806 and 9801, depending on what I put on the .plist file:
MY CODE: In my Info.plist file, I have:
In my ObjectiveC code, I have this:
In the DELEGATE method of the class where make the URLSession call, I can see didReceiveChallenge:
. and finally I get the error:
THE SERVER None of the solutions proposed in other answers work, is it because of Apple’s 2017 deadline? https://techcrunch.com/2016/06/14/apple-will-require-https-connections-for-ios-apps-by-the-end-of-2016/ According to this online security analysis tool, https://www.ssllabs.com/ssltest/analyze.html The backend DOES support TLS 1.2
Any ideas on how to solve this?? Do you know where to find some iOS sample code to be 100% sure the endpoint I am pointing at is guilt free?
UPDATE This code works for me, any opinions on it?:
3 Answers 3
Try to set NSExceptionRequiresForwardSecrecy to false. However your server do meet the min requirement for Transport Layer Security (TLS) protocol version, your server Connection-Cipher may not support forward secrecy.
The negotiated Transport Layer Security (TLS) version must be TLS 1.2. Attempts to connect without TLS/SSL protection, or with an older version of TLS/SSL, are denied by default.
The connection must use either the AES-128 or AES-256 symmetric cipher.
The negotiated TLS connection cipher suite must support perfect forward secrecy (PFS) through Elliptic Curve Diffie-Hellman Ephemeral (ECDHE) key exchange, and must be one of the following:
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
Источник
NSURLConnection завершилось с ошибкой — код -1002
Друзья у меня есть простой аудиоплеер (MPMoviePlayerController) который может воспроизводить аудиопоток. На iOS 11 у меня очень интерисует беда, тысячу раз у меня error и мой поток останавливался:
Я вставляю этот код (этот код я видел на stackowerflow) но он мне не помагает:
Может вы знаете лучшее решение?
3 ответа
Хочу открыть даный url в webview без https (пример myDomain.com). Получаю ошибку NSURLConnection finished with error — code -1100 Ошибка для swift открытия url на Android. Как мне это сделать? let url = URL(string: myDomain.com) webView.loadRequest(URLRequest(url: url!))
Получаю Error: NSURLConnection finished with error — code -1009 in iOS 11, Xcode 9 когда собираюсь в background и wifi off.. его вставание непрерывно вплоть до wifi on и любого у него есть решение.
Та ошибка должна not должна иметь отношение к использованию HTTP вместо HTTPS. Сбои системы безопасности транспорта App возвращают код ошибки -1022.
Код ошибки -1002 указывает на невалидный URL. Возможно, ваш файл HTTP live streaming плейлист содержит структурно невалидный URL (e.g. missing scheme, схема, отличная от http/https и т.д.)?
Для дополнительной отладки задайте в вашем проекте Xcode эту переменную окружения
и заново запустите app. Как только вы знаете, какой URL сбой, проблема, скорее всего, станет более очевидной.
Если это не так, подайте баг.
Данный вопрос может появиться, если ваш URL содержит пробелы. Я решил его, заменив пробелы на «%20», и тогда вы можете использовать его безопасно. Код на Objective C для замены пробелов находится ниже.
Первым делом вы должны использовать secure server (сервер с валидным сертификатом). Я не уверен нужно это или нет потому что я никогда не пытался ударить server с невалидным сертификатом. Можете попробовать этот код (не уверен будет у вас работать или нет) положить этот код в Appdelegate.m
Похожие вопросы:
Когда я попадаю на сервер логина, то получаю вот такое сообщение об ошибке: NSURLConnection finished with error — code -1202. Я в свой Plist добавил App transport security и у меня все невалидные.
Во первых, url недостающий, когда вебвью вызвал loadRequest, в нем есть два сообщения об ошибке. А метод UIWebViewDelegate didFailLoadWithError не удалось вызвать. NSURLConnection finished with.
Я получаю вот такую ошибку NSURLConnection закончил с ошибкой — код -1002. У меня добавлен код ниже в мой info.plist. Кто-нибудь знает почему? Заранее спасибо.
Хочу открыть даный url в webview без https (пример myDomain.com). Получаю ошибку NSURLConnection finished with error — code -1100 Ошибка для swift открытия url на Android. Как мне это сделать? let.
Получаю Error: NSURLConnection finished with error — code -1009 in iOS 11, Xcode 9 когда собираюсь в background и wifi off.. его вставание непрерывно вплоть до wifi on и любого у него есть решение.
Когда я отправляю запрос и получаю ошибку с кодом ошибки -1009 , что это значит? Я не уверен как это обработать. — (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error<.
Мы пытаемся сделать приложение-газету iPad для нашего университета. Наша попытка заключалась в том, чтобы напрямую парсить с сайта газеты с помощью NSXMLParser. Нам удалось спарсить заголовки. Что я.
У меня есть приложение, которое требует a для общения с другим устройством с помощью UDP . Я использую фреймворк GCDAsyncUDPSocket . Я не знаю порт, который потребуется пересылать, пока я впервые не.
Что такое NSURLConnection finished with error — code -1100 ? Я получаю эту ошибку во время загрузки изображения с камеры в iOS build. Я работаю в ionic 1. Как этот вопрос можно исправить?
Ребят пытаюсь выучить webview оно не может подгрузить мне выдают ошибку вроде: NSURLConnection finished with error — code -1022 — (void)viewDidLoad < [super viewDidLoad]; NSString *urlString =.
Источник
У меня была такая же проблема, но у меня было другое дело. Вот код, который сгенерировал ошибку:
if let url = URL(string: imageUrl){
getDataFromUrl(url: url) { data, response, error in
DispatchQueue.main.async() {
if let imageFile = UIImage(data: data) {
self.createItem(forModule: module, title: title, description: description, date: date, image: imageFile, table: table)
} else {
self.createItem(forModule: module, title: title, description: description, date: date, image: nil, table: table)
}
}
}
} else { print("invalid url") }
private func getDataFromUrl(url: URL, completion: @escaping (Data?, URLResponse?, Error?) -> ()) {
URLSession.shared.dataTask(with: url) { data, response, error in
completion(data, response, error)
}.resume()
}
Позже я узнал, что imageUrl на самом деле не был URL-адресом, это была просто строка, буквально «ложная». и что сделало его еще хуже, что он не был пойман во всех остальных заявлениях.
поэтому я решил это, просто добавив охранник ниже:
if let url = URL(string: imageUrl){
getDataFromUrl(url: url) { data, response, error in
guard let data = data, error == nil else {
self.createItem(forModule: module, title: title, description: description, date: date, image: nil, table: table)
return
}
DispatchQueue.main.async() {
if let imageFile = UIImage(data: data) {
self.createItem(forModule: module, title: title, description: description, date: date, image: imageFile, table: table)
} else {
self.createItem(forModule: module, title: title, description: description, date: date, image: nil, table: table)
}
}
}
}
Теперь я могу вызвать функцию createItem и сохранить свой элемент без изображения. Поэтому тщательно проверяйте свои URL-адреса, если вы получаете их от API.
Friends i have simple audio player (MPMoviePlayerController) which can play audio stream. On iOS 11 i have very interessing trouble, thousand time i have error and my stream was stopped:
NSURLConnection finished with error - code -1002
I paste this code (this code i saw on stackowerflow) but it’s not help to me:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>cast.mysite.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
Maybe you know best solution?
3 Answers
That error should not be related to using HTTP instead of HTTPS. App Transport Security failures return error code -1022.
The error code -1002 indicates an invalid URL. Perhaps your HTTP live streaming playlist file contains a structurally invalid URL (e.g. missing scheme, a scheme other than http/https, etc.)?
For additional debugging, set this environment variable
CFNETWORK_DIAGNOSTICS=1
in your Xcode project and re-run the app. Once you know what URL is failing, the problem will likely become more obvious.
If it isn’t, file a bug.
This issue can appear if your URL contains spaces. I solved it by replacing the spaces with «%20», and then you can use it safely. The Objective C code to replace the spaces is below.
your_url_variable_name = [your_url_variable_name stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
First thing you must use secure server (server with valid certificate).
I’m not sure either it is necessary or not because i never tried to hit server with invalid certificate. You can try this code (not sure it will work for you or not) put this code in Appdelegate.m
@implementation NSURLRequest(DataController)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host
{
return YES;
}
@end