1

我正在为 iOS 应用程序尝试 SPDY,该应用程序当前使用 AFNetworking (2.1.0) 来处理 HTTP 请求。服务器端,我使用的是 Google App Engine(使用SPDYCheck检查)它是 SPDY 友好的。

这是我在代码中集成 SPDY 的方式。

我正在使用 AFHTTPRequestOperationManager

@interface MyClient : AFHTTPRequestOperationManager

我将 SPDY 嵌入到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];
    ...
  }

请注意,我的网址是格式https://myapp.appspot.com/_ah/所以我在传递给 SPDY 时重新格式化registerOrigin:spdyURL 看起来像https://myapp.appspot.com:443

我想这就是我所需要的?但是添加 SPDY 代码后我无法发送请求。调试消息显示以下错误:

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."}

我一点头绪都没有。希望有在 iOS 上使用 SPDY 经验的人可以提供帮助!

4

3 回答 3

3

确实,Apple 在默认 TLS 实现中不支持 NPN。但是有一些 SPDY 库使用 OpenSSL(支持 NPN)。

这是其中之一: https ://github.com/locationlabs/SPDY-for-iPhone

于 2014-03-08T21:59:40.663 回答
2

不幸的是,Apple 的 TLS 实现不支持 Google App Engine 使用的 NPN。您可以在CocoaSPDY GitHub README中阅读更多相关信息。

您目前无法将 CocoaSPDY 与 Google App Engine 一起使用。

于 2014-03-07T12:18:10.150 回答
0

你可以吗?我看到 SPDY 协议支持现在在 OS X Yosemite 和 iOS 8 上的 NSURLSession 中可用,并且由 NSURLSession 透明地支持。查看详情:https://developer.apple.com/videos/wwdc/2014/ [Foundation Networking 的新功能] 但是为什么它不起作用?当我使用 CocoaSPDY 时,设置 manager.session.configuration.protocolClasses=@[[SPDYURLSessionProtocol class]]; 没关系;

于 2015-08-18T08:46:01.350 回答