jetty+dwr实现Comet Web应用 ,页面刷新时常出现异常"远程主机强迫关闭了一个现有的连接"

用jetty7+dwr2.06实现Comet,往页面push数据,页面刷新时,经常会出现以下异常信息,但异常并不妨碍功能的实现,照样可以push数据,,不过老打出异常总感到不爽,不知道是否有人遇到过,希望能给点解决的线索:

2010-5-11 22:43:38 org.directwebremoting.util.CommonsLoggingOutput warn
警告: Unhandled Exception
org.eclipse.jetty.io.RuntimeIOException: org.eclipse.jetty.io.EofException
at org.eclipse.jetty.io.UncheckedPrintWriter.write(UncheckedPrintWriter.java:223)
at org.eclipse.jetty.io.UncheckedPrintWriter.write(UncheckedPrintWriter.java:235)
at org.eclipse.jetty.io.UncheckedPrintWriter.print(UncheckedPrintWriter.java:384)
at org.eclipse.jetty.io.UncheckedPrintWriter.println(UncheckedPrintWriter.java:542)
at org.directwebremoting.dwrp.PlainScriptConduit.addScript(PlainScriptConduit.java:86)
at org.directwebremoting.extend.EnginePrivate.remoteHandleException(EnginePrivate.java:118)
at org.directwebremoting.dwrp.BaseScriptConduit.close(BaseScriptConduit.java:111)
at org.directwebremoting.dwrp.PollHandler$1.run(PollHandler.java:199)
at org.directwebremoting.dwrp.ThreadWaitSleeper.goToSleep(ThreadWaitSleeper.java:45)
at org.directwebremoting.dwrp.PollHandler.handle(PollHandler.java:211)
at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:101)
at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:146)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:530)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:427)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:457)
at org.eclipse.jetty.server.session.SessionHandler.handle(SessionHandler.java:182)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:933)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:362)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:867)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:245)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:113)
at org.eclipse.jetty.server.Server.handle(Server.java:334)
at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:559)
at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:1007)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:747)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:203)
at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:406)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:462)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:436)
at java.lang.Thread.run(Unknown Source)
Caused by: org.eclipse.jetty.io.EofException
at org.eclipse.jetty.http.HttpGenerator.flushBuffer(HttpGenerator.java:885)
at org.eclipse.jetty.http.AbstractGenerator.blockForOutput(AbstractGenerator.java:486)
at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:145)
at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:86)
at java.io.ByteArrayOutputStream.writeTo(Unknown Source)
at org.eclipse.jetty.server.HttpWriter.write(HttpWriter.java:258)
at org.eclipse.jetty.server.HttpWriter.write(HttpWriter.java:107)
at org.eclipse.jetty.io.UncheckedPrintWriter.write(UncheckedPrintWriter.java:214)
... 34 more
Caused by: java.io.IOException: 远程主机强迫关闭了一个现有的连接。
at sun.nio.ch.SocketDispatcher.writev0(Native Method)
at sun.nio.ch.SocketDispatcher.writev(Unknown Source)
at sun.nio.ch.IOUtil.write(Unknown Source)
at sun.nio.ch.SocketChannelImpl.write0(Unknown Source)
at sun.nio.ch.SocketChannelImpl.write(Unknown Source)
at java.nio.channels.SocketChannel.write(Unknown Source)
at org.eclipse.jetty.io.nio.ChannelEndPoint.flush(ChannelEndPoint.java:237)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.flush(SelectChannelEndPoint.java:221)
at org.eclipse.jetty.http.HttpGenerator.flushBuffer(HttpGenerator.java:818)
... 41 more
2010-05-11 22:43:38.463:WARN::Committed before 501 Error. Details logged to the console

个人觉得,应该是页面刷新时,创建了新的长连接,jetty必须关闭先前的长连接,dwr或jetty封装的时候,异常没处理好,应该是其本身的bug.曾尝试用sessionListener去拦截,当请求来的时候,检查有没有先前创建的该url对应的ScriptSession:如有,则去掉,保存本次请求的ScriptSession.但不管用,还没执行到sessionListener异常就打印出来了,也就是说,先前的长连接已经被强制关闭了.
第一次jetty+dwr,很不得要领.

gwt

1个回答

可能的原因:
1,你发送的数据不符合规定,比如你发163的邮箱就很可能这样。
2,对方已经发送完了数据,并正常关闭了,你无法再次发送数据了。
3,到达文件末尾,或是文件已经读完后还在读文件。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问