Netty 4.0 SPDY文件传输无法正常工作(Netty 4.0 SPDY file transfer not working)
很长一段时间,当我尝试使用带有netty的SPDY时,我总是遇到同样的麻烦。
我检查了不同的SPDY源来设置我的SPDY服务器。 到目前为止它工作正常,我的浏览器有一个纯html输出。 Chrome还会显示一个spdy会话。
问题
当我将netty 4
SPDYorHTTPHandler
示例类放到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()); }
但它永远不会写。 代码基于
HttpStaticFileServerHandler
示例和netty 4的SPDY示例100%。我刚刚将
createHttpRequestHandlerForHttp output
更改为createHttpRequestHandlerForHttp output
。这是我使用的桩线:
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());
如果您需要更多代码,请写,我将扩展Post。
我没有错误,警告或其他。
ChannelProgressiveFutureListener
从未调用operationProgressed
函数。Thx渡渡鸟。
For a long time I always run into the same trouble when i try to use SPDY with netty.
I checked different SPDY sources to setup my SPDY server. So far it works fine and I have got a pure html output in my browser. Chrome also shows an spdy session.
Issue
When i put the netty 4
HttpStaticFileServerHandler
example class to theSPDYorHTTPHandler
I always run into the same problem.HTML content is sent, but the file content isn't. The handler is sending the response so my client retrieves, but then the files are never transmitted.
Any ideas about that?
ctx.write(response)
is writing the response to the client (response is aHttpResponse
obj).In the next line:(
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()); }
But it never gets written. The code based 100% on the
HttpStaticFileServerHandler
example and the SPDY example of netty 4.I just changed the
createHttpRequestHandlerForHttp output
fromSpdyServerHandler
toHttpStaticFileServerHandler
.This is the pileline I use:
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());
If you need more code for that, just write, I will extend the Post.
I got no errors, warnings or something else.
A
ChannelProgressiveFutureListener
did never calloperationProgressed
function.Thx dodo.
原文:https://stackoverflow.com/questions/24342830