Question

I'm trying SPDY for iOS app, which currently uses AFNetworking (2.1.0) to handle HTTP requests. Server side, I'm using Google App Engine (Checked with SPDYCheck) it's SPDY-friendly.

Here's how I integrated SPDY in my code.

I'm using AFHTTPRequestOperationManager

@interface MyClient : AFHTTPRequestOperationManager

And I embedded SPDY in initWithBaseURL:

- (id)initWithBaseURL:(NSURL *)url {
    self = [super initWithBaseURL:url];
    if (!self) {
        return nil;
    }

    // SPDY Config
    NSString *spdyURL = [NSString stringWithFormat:@"%@://%@:443",url.scheme, url.host];

    [SPDYURLConnectionProtocol registerOrigin:spdyURL];
    ...
  }

Note that my url is with format https://myapp.appspot.com/_ah/ So I reformat it when passing to SPDY registerOrigin: spdyURL will look like https://myapp.appspot.com:443

I suppose that's all I need? But I wasn't able to send request after adding the SPDY code. Debug message showed the following error:

error response from api/users/v1/is_token_valid :
Error Domain=NSURLErrorDomain 
Code=-1001 
"The request timed out." 
UserInfo=0xdc2c250 {NSErrorFailingURLStringKey=https://myapp.appspot.com/_ah/api/users/v1/is_token_valid?
user_token=[a_token], 
NSErrorFailingURLKey=https://myapp.appspot.com/_ah/api/users/v1/is_token_valid?
user_token=[a_token], 
NSLocalizedDescription=The request timed out., NSUnderlyingError=0xf270e60 "The request timed out."}

I have no clue at all. Hope someone with experience with SPDY on iOS could help!!

Was it helpful?

Solution 2

Unfortunately Apple's TLS implementation doesn't support NPN which is used by Google App Engine. You can read more about it in the CocoaSPDY GitHub README.

You can't use CocoaSPDY with Google App Engine at this time.

OTHER TIPS

It is true that Apple does not support NPN in default TLS implementation. However there are some SPDY libs using OpenSSL (which supports NPN).

Here is one on them: https://github.com/locationlabs/SPDY-for-iPhone

Is it ok for you? I see that SPDY protocol support is now available in NSURLSession on OS X Yosemite and iOS 8 , and is Supported transparently by NSURLSession. see details: https://developer.apple.com/videos/wwdc/2014/ [What's New in Foundation Networking] But why it not work? When i use CocoaSPDY, set manager.session.configuration.protocolClasses=@[[SPDYURLSessionProtocol class]]; it's ok;

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top