我试图从 iOS 设备上的远程服务器流式传输 mp4 视频。我不知何故
[ERROR] Error while writing to socket 15: Broken pipe (32)
写了几封信。
不知道哪里错了。你能提供任何建议吗?
带有 GCDWebServer 的 iOS 重新路由请求(不重定向)
谢谢!饶
@property (nonatomic, strong) GCDWebServerBodyReaderCompletionBlock cb;
[_webServer addDefaultHandlerForMethod:@"GET"
requestClass:[GCDWebServerRequest class]
processBlock:^GCDWebServerResponse *(GCDWebServerRequest* request) {
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration ephemeralSessionConfiguration];
self.session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:[NSOperationQueue mainQueue]];
GCDWebServerStreamedResponse* response = [GCDWebServerStreamedResponse responseWithContentType:@"application/octet-stream" asyncStreamBlock:^(GCDWebServerBodyReaderCompletionBlock completionBlock) {
NSString * realURL = @"https://ia800309.us.archive.org/2/items/Popeye_Nearlyweds/Popeye_Nearlyweds_512kb.mp4";
self.cb = completionBlock;
NSURLSessionDataTask * dataTask = [self.session dataTaskWithURL:[[NSURL alloc] initWithString:realURL]] ;
}];
return response;
}];
(void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask
didReceiveResponse:(NSURLResponse *)response
completionHandler:(void (^)(NSURLSessionResponseDisposition disposition))completionHandler
{
self.response = response;
completionHandler(NSURLSessionResponseAllow);
}
(void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask
didReceiveData:(NSData *)data
{
NSLog(@"got data size == %lu", data.length);
self.cb(data, nil);
}
(void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task
didCompleteWithError:(NSError *)error
{
self.cb([NSData data], nil);
}
[DEBUG] Did open IPv4 listening socket 6
[DEBUG] Did open IPv6 listening socket 7
[INFO] GCDWebServer started on port 8080 and reachable at http://192.168.1.27:8080/
2016-02-23 15:34:39.096 Proxy2Proxy[5315:1148991] Visit http://192.168.1.27:8080/ in your web browser
[DEBUG] Did open connection on socket 15
[DEBUG] Did connect
[DEBUG] Did start background task
[DEBUG] Connection received 370 bytes on socket 15
[DEBUG] Connection on socket 15 preflighting request "GET /https://ia800309.us.archive.org/2/items/Popeye_Nearlyweds/Popeye_Nearlyweds_512kb.mp4" with 370 bytes body
[DEBUG] Connection on socket 15 processing request "GET /https://ia800309.us.archive.org/2/items/Popeye_Nearlyweds/Popeye_Nearlyweds_512kb.mp4" with 370 bytes body
[DEBUG] Connection sent 175 bytes on socket 15
2016-02-23 15:34:47.488 Proxy2Proxy[5315:1148991] got data size == 16059
[DEBUG] Connection sent 16067 bytes on socket 15
2016-02-23 15:34:47.488 Proxy2Proxy[5315:1148991] got data size == 32768
[DEBUG] Connection sent 32776 bytes on socket 15
2016-02-23 15:34:47.489 Proxy2Proxy[5315:1148991] got data size == 32768
[DEBUG] Connection sent 32776 bytes on socket 15
2016-02-23 15:34:47.489 Proxy2Proxy[5315:1148991] got data size == 98304
2016-02-23 15:34:47.490 Proxy2Proxy[5315:1148991] got data size == 16384
[DEBUG] Connection sent 98313 bytes on socket 15
[DEBUG] Connection sent 16392 bytes on socket 15
2016-02-23 15:34:47.506 Proxy2Proxy[5315:1148991] got data size == 16384
[DEBUG] Connection sent 16392 bytes on socket 15
2016-02-23 15:34:47.517 Proxy2Proxy[5315:1148991] got data size == 16384
[DEBUG] Connection sent 16392 bytes on socket 15
2016-02-23 15:34:47.530 Proxy2Proxy[5315:1148991] got data size == 16384
[DEBUG] Connection sent 16392 bytes on socket 15
2016-02-23 15:34:47.545 Proxy2Proxy[5315:1148991] got data size == 16384
[ERROR] Error while writing to socket 15: Broken pipe (32)