NSURLConnection finished with error - code -1002 - xcode

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?

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

Related

WSOS GREG : redirect to url not supporting offset

Using Registry 5.1 - Any attempt to add a wsdl, displays a depreciated message, 'use https://localhost:9445/publisher', but any attempt to use this url fails because the subsequent login screen doesn't seem to know about the port 'offset' feature - basically I suspect there is a bug when Registry is not deployed on the default port.
https://localhost:9443/publisher/acs?loginStatus=true
i.e. its using wrong port should be + 1
Possibly finger trouble? should this work & I'm missing something?
In order to access publisher and store after port offset, you need to change the content of the <GREG_HOME>/repository/conf/identity/sso-idp-config.xml. You need to specify the correct port number in that file. Please refer to the following config; here port offset of 3 is used:
<AssertionConsumerService>https://localhost:9446/publisher/acs</AssertionConsumerService>

Break on kCFStreamErrorDomainSSL

I'm trying to debug an app that makes a lot of HTTP calls. I'm seeing this in the console:
2015-09-08 17:21:01.458 MyApp[3186:3064431] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)
I understand how to add exceptions to my plist, but is there way to add a breakpoint where these requests are failing to see what is being requested?
I wasn't able to make much of the stack trace when adding those breakpoints; however, this blog post helped me figure out which domains were failing:
http://timekl.com/blog/2015/08/21/shipping-an-app-with-app-transport-security/
tl;dr: set the environment variable CFNETWORK_DIAGNOSTICS to 1 (how to set environment variables, if you need a hand: http://nshipster.com/launch-arguments-and-environment-variables/). this will log all the CFNetwork activity to a file that you'll see in the console; search that file for 'Did Fail' and you can see which requests are failing and why.
Try adding a symbolic breakpoint in HTTPProtocol::failWithStreamError and/or StrictSecurityPolicy::logInsecureLoadFailure.
(This unfortunately may not make it easy to get the stack trace of the actual request, since this exception occurs asynchronously with the actual request creation code. But it might help you anyway.)
While working with iOS 9, We have to put below lines in info.plist otherwise no any API call will work.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>dev.YourCompanyName.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<false/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<true/>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSRequiresCertificateTransparency</key>
<false/>
</dict>
</dict>
</dict>

Mac App Rejection - Temporary Exception Entitlement Key for Safari

Let's consider an app doing the following steps using AppleScript, in order to auto-login to some website:
1- Open "Safari" and navigate to website
2- Fill the username and password fields with JavaScriptdo JavaScript " document.getElementById('password_input').value = 'userPassword' "
3- Submit form using JavaScript --- do JavaScript " document.forms['login_form'].submit() "
For a sandboxed Mac app, com.apple.security.temporary-exception.apple-events entitlement key must be added for "Safari", in order to execute AppleScript procedure above.
<key>com.apple.security.temporary-exception.apple-events</key>
<array>
<string>com.apple.safari</string>
</array>
Everything works great this way, without any problem.
Here is my question:
Does the app get rejected because of this temporary exception usage for Safari?
After waiting for more than one month, my app got approved.
In entitlements section of iTunesConnect, I briefly explained why I used this entitlement key, and my app got approved without any problem.
So I can say that temporary exception usage for Safari is NOT a reject reason.
Looks like it :
https://github.com/TheRealKerni/QuincyKit/issues/109
In particular see comment from Ishuo

'Security error" code: "1000' in Audio API example

I'm trying to repeat the example from here, but am getting this error:
Security error" code: "1000
var fb = event.frameBuffer,
Everything in my folder have 777 rights, but it's still is giving me it. My Firefox version is 4.0, so Audio API features should be available. What could be the problem? I've copied the example without any change. Any suggestion would help, thank you.
You have to make sure your audio and web page are same origin, and if you're doing this from a file:/// URI, you have to tell Firefox to not force origin checks, see our note here: https://wiki.mozilla.org/Audio_Data_API#Security

Service reference addition issue in visual studio 2010

I am currently working on an application that allows reverse geocoding using silverlight + bing maps. The thing is that I want to add a reference to the reverse geocoding service provided in msdn ( http://msdn.microsoft.com/en-us/library/cc879136.aspx) i.e. http:// dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc?wsdl, but when I try to get a reference in vs2010, I get the following error:
The document at the url http:// dev.virtualearth.net/webservices/v1/metadata/geocodeservice/geocodeservice.wsdl was not recognized as a known document type.
The error message from each known type may help you fix the problem:
Report from 'XML Schema' is ''', hexadecimal value 0x1F, is an invalid character. Line 1, position 1.'.
Report from 'DISCO Document' is ''', hexadecimal value 0x1F, is an invalid character. Line 1, position 1.'.
Report from 'WSDL Document' is 'There is an error in XML document (1, 1).'.
'', hexadecimal value 0x1F, is an invalid character. Line 1, position 1.
Metadata contains a reference that cannot be resolved: 'http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc?wsdl'.
Content Type application/soap+xml; charset=utf-8 was not supported by service http: //dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc?wsdl. The client and service bindings may be mismatched.
The remote server returned an error: (415) Unsupported Media Type.
If the service is defined in the current solution, try building the solution and adding the service reference again.
It is good to mention that I can access the service URL from the browser (with a no style information warning). I am aware that there are other reverse geolocoding services out there, but I am somewhat forced by certain circumstances to use only Microsoft-related components/services. Please help :)
I've just tried the same thing and it seems to work fine for me. I saw an article on the MSDN newsgroups that suggest there may have been a problem at some stage with the references (see a post on Bing Map Route Calculation Service) although it mentions that it was the staging URL's that were causing a problem, not those that you're using (as in the article currently). Other than that, are you using the current RC of VS2010? (on the off chance that there were issues in an earlier version)
Might be worth trying again; I've whipped up a stub application at http://code.google.com/p/bingmapssilverlightapp/downloads/list if it's any use.

Resources