【发布时间】:2014-08-12 03:07:21
【问题描述】:
很长一段时间以来,当我尝试将 SPDY 与 netty 一起使用时,我总是遇到同样的问题。
我检查了不同的 SPDY 源来设置我的 SPDY 服务器。到目前为止,它工作正常,我的浏览器中有一个纯 html 输出。 Chrome 还会显示一个 spdy 会话。
问题
当我将 netty 4 HttpStaticFileServerHandler 示例类放到 SPDYorHTTPHandler 时,我总是遇到同样的问题。
发送 HTML 内容,但不发送文件内容。处理程序正在发送响应,以便我的客户端检索,但文件永远不会传输。
对此有什么想法吗?
ctx.write(response) 正在向客户端写入响应(响应为HttpResponse obj)。
在下一行:(raf=RandomAccessFile)
ChannelFuture sendFileFuture;
if (useSendFile) {
sendFileFuture = ctx.write(new DefaultFileRegion(raf.getChannel(), 0, fileLength), ctx.newProgressivePromise());
} else {
sendFileFuture = ctx.write(new ChunkedFile(raf, 0, fileLength, 8192), ctx.newProgressivePromise());
}
但它永远不会被写入。该代码 100% 基于 HttpStaticFileServerHandler 示例和 netty 4 的 SPDY 示例。
我刚刚将 createHttpRequestHandlerForHttp output 从 SpdyServerHandler 更改为 HttpStaticFileServerHandler。
这是我使用的桩线:
ChannelPipeline pipeline = ctx.pipeline();
pipeline.addLast("spdyFrameCodec", new SpdyFrameCodec(version));
pipeline.addLast("spdySessionHandler", new SpdySessionHandler(version,true));
pipeline.addLast("spdyHttpEncoder", new SpdyHttpEncoder(version));
pipeline.addLast("spdyHttpDecoder", new SpdyHttpDecoder(version, MAX_CONTENT_LENGTH));
pipeline.addLast("spdyStreamIdHandler", new SpdyHttpResponseStreamIdHandler());
pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());
pipeline.addLast("httpRequestHandler",new HttpStaticFileServerHandler());
如果您需要更多代码,请写,我会扩展帖子。
我没有收到任何错误、警告或其他信息。
ChannelProgressiveFutureListener 从未调用过 operationProgressed 函数。
谢谢渡渡鸟。
【问题讨论】: