iteye_9323 2010-05-11 23:30
浏览 365
已采纳

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,很不得要领.

  • 写回答

1条回答 默认 最新

  • 紫翎观星 2010-05-12 11:27
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化