Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Tyrus websocket服务器握手问题?_Websocket_Tyrus - Fatal编程技术网

Tyrus websocket服务器握手问题?

Tyrus websocket服务器握手问题?,websocket,tyrus,Websocket,Tyrus,我遵循可用的用户指南:我在pom中添加了以下内容: <dependency> <groupId>org.glassfish.tyrus</groupId> <artifactId>tyrus-server</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>org.gla

我遵循可用的用户指南:我在pom中添加了以下内容:

<dependency>
  <groupId>org.glassfish.tyrus</groupId>
  <artifactId>tyrus-server</artifactId>
  <version>1.2</version>
</dependency>
<dependency>
  <groupId>org.glassfish.tyrus</groupId>
  <artifactId>tyrus-container-grizzly</artifactId>
  <version>1.2</version>
</dependency>
我的EchondPoint类的内容与前面描述的相同

我试图用HTML5 websocket连接到这一点:

var ws = new WebSocket("ws://localhost:8624/echo");
在浏览器端,它似乎没有连接(它直接调用onClose回调)。在服务器端,我在控制台中看到:

Grave: Invalid Connection header returned: 'keep-alive'
org.glassfish.tyrus.websockets.HandshakeException: Invalid Connection header returned: 'keep-alive'
    at org.glassfish.tyrus.websockets.HandShake.validate(HandShake.java:254)
    at org.glassfish.tyrus.websockets.HandShake.checkForHeader(HandShake.java:246)
    at org.glassfish.tyrus.websockets.HandShake.<init>(HandShake.java:97)
    at org.glassfish.tyrus.websockets.draft06.HandShake06.<init>(HandShake06.java:63)
    [...]
org.glassfish.grizzly.filterchain.DefaultFilterChain execute
Avertissement: Exception during FilterChain execution
java.lang.ClassCastException: org.glassfish.grizzly.http.HttpContent cannot be cast to org.glassfish.tyrus.websockets.DataFrame
    at org.glassfish.tyrus.container.grizzly.WebSocketFilter.handleWrite(WebSocketFilter.java:330)
这是握手问题吗


编辑:我已经在Chrome(28.0.1500.72)中进行了尝试,并且效果良好。可能是Firefox在构建标题时出现了问题?

Tyrus正在抱怨
连接:保持活动,升级
标题

Firefox在这里没有做错任何事

Tyrus限制太多,在如何处理连接头方面没有遵循WebSocket规范()

RFC声明如下:


这似乎是Tyrus中的一个bug。

谢谢你的回答(我读得有点晚)。我以为这个“升级”令牌的事情被纠正了。也许不行?好吧,我换个pom试试。我猜是不是有关系?
Grave: Invalid Connection header returned: 'keep-alive'
org.glassfish.tyrus.websockets.HandshakeException: Invalid Connection header returned: 'keep-alive'
    at org.glassfish.tyrus.websockets.HandShake.validate(HandShake.java:254)
    at org.glassfish.tyrus.websockets.HandShake.checkForHeader(HandShake.java:246)
    at org.glassfish.tyrus.websockets.HandShake.<init>(HandShake.java:97)
    at org.glassfish.tyrus.websockets.draft06.HandShake06.<init>(HandShake06.java:63)
    [...]
org.glassfish.grizzly.filterchain.DefaultFilterChain execute
Avertissement: Exception during FilterChain execution
java.lang.ClassCastException: org.glassfish.grizzly.http.HttpContent cannot be cast to org.glassfish.tyrus.websockets.DataFrame
    at org.glassfish.tyrus.container.grizzly.WebSocketFilter.handleWrite(WebSocketFilter.java:330)
GET /echo HTTP/1.1
Host: localhost:8624
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0 FirePHP/0.7.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
DNT: 1
Sec-WebSocket-Version: 13
Origin: null
Sec-WebSocket-Key: yhGPwJ26c5fYEZ5/abvtqw==
x-insight: activate
Connection: keep-alive, Upgrade
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket
   6.   The request MUST contain a |Connection| header field whose value
        MUST include the "Upgrade" token.
   3.  If the response lacks a |Connection| header field or the
       |Connection| header field doesn't contain a token that is an
       ASCII case-insensitive match for the value "Upgrade", the client
       MUST _Fail the WebSocket Connection_.