2014-12-01 147 views
0

我有当被注释掉Thread.sleep()被放回代码是用Java作为WebSocket的的Tomcat的WebSocket客户端框架

protected void dequeue() throws InterruptedException, IOException 
    { 
     ByteBuffer bbuf; 
     System.out.println("start"); 
     while((bbuf = messageQueue.take()).get(0) != 0) 
     { 
      bbuf.position(bbuf.limit()); 
      if(bbuf.get(0)== 0) 
       System.out.println("here"); 
      bbuf.flip(); 
      for(Session session : sessionList) 
      { 
       //Thread.sleep(10000); 
       if(!session.isOpen()) 
        break; 
       session.getBasicRemote().sendBinary(bbuf); 
      } 
     } 
     System.out.println("end"); 
    } 

代码的clientendpoint执行以下代码工作正常。然而,当在码不包括Thread.sleep()的写入到的WebSocket有时工作,其它时间被写入后的第一消息和以下原因给出@onClose被调用时,

CloseReason: code [1002], reason [The client frame set the reserved bits to [7] which was not supported by this endpoint]

在其中[7]有时候会是1,2等。我一直无法找到任何真正的原因,为什么会有这种情况发生,有没有人碰巧对发生的事情有所了解?请注意,我使用tomcat 7.0.53来托管websocket的ServerSide,并使用HTTPS而不是HTTP。

回答