“IE 11″中的Websocket onOpen后出现EOF异常。

huangapple go评论70阅读模式
英文:

EOF Exception after Websocket onOpen from IE 11

问题

我正在使用javax WebSocket服务器与JavaScript。除了IE(尝试过IE 11和10),所有其他浏览器都可以进行WebSocket连接。虽然onOpen被调用并且连接成功,但之后会抛出带有空错误消息的EOFException。下面是错误的堆栈跟踪信息:

java.io.EOFException
        at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.fillReadBuffer(NioEndpoint.java:1250)
        at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.read(NioEndpoint.java:1190)
        at org.apache.tomcat.websocket.server.WsFrameServer.onDataAvailable(WsFrameServer.java:72)
        at org.apache.tomcat.websocket.server.WsFrameServer.doOnDataAvailable(WsFrameServer.java:171)
        at org.apache.tomcat.websocket.server.WsFrameServer.notifyDataAvailable(WsFrameServer.java:151)
        at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler.upgradeDispatch(WsHttpUpgradeHandler.java:148)
        at org.apache.coyote.http11.upgrade.UpgradeProcessorInternal.dispatch(UpgradeProcessorInternal.java:54)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:53)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:748)

基本上,我无法确定这是服务器端问题还是客户端问题。我是否需要在客户端或服务器端引入超时?还是连接会立即关闭,我需要引入ping-pong帧?请帮我解决这个问题!

英文:

I'm using a javax websocket server with javascript.
Websocket connection happens with the all other browsers except for IE (tired with IE 11 and 10).
onOpen is called and connection happens, after that EOFException is thrown with empty error message. Below is the stacktrace of the error

java.io.EOFException
        at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.fillReadBuffer(NioEndpoint.java:1250)
        at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.read(NioEndpoint.java:1190)
        at org.apache.tomcat.websocket.server.WsFrameServer.onDataAvailable(WsFrameServer.java:72)
        at org.apache.tomcat.websocket.server.WsFrameServer.doOnDataAvailable(WsFrameServer.java:171)
        at org.apache.tomcat.websocket.server.WsFrameServer.notifyDataAvailable(WsFrameServer.java:151)
        at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler.upgradeDispatch(WsHttpUpgradeHandler.java:148)
        at org.apache.coyote.http11.upgrade.UpgradeProcessorInternal.dispatch(UpgradeProcessorInternal.java:54)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:53)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:748)

Basically, I'm not able to figure out if it's server side or client side issue. Is there a timeout that I need to introduce from the client or server? or is the connection getting closed immediately and I need to introduce a ping-pong frame for that? Please help me out!

答案1

得分: 0

我找到了解决方案。

基本上,我们需要检查IE浏览器中的请求和响应头,因为在IE浏览器中,请求和响应头与其他浏览器中的不同。
我使用了“sec-webSocket-protocol”,在其他浏览器中,该头的值会创建空格,而在IE 11中则没有这样的空格。
因此,返回我收到的相同头部解决了这个问题。

英文:

I found the solution for it.

Basically, we need to check the request and respond headers in the IE, the request and response headers weren't the same as they were in other browser.
I have using the "sec-webSocket-protocol" where the value for this header was creating spaces in other browsers and there were no such spaces in IE 11.
Hence returning the same header which I received solved the issue

huangapple
  • 本文由 发表于 2020年8月28日 19:48:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/63633212.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定