Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.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
Java 握手后Web套接字断开?_Java_Google Chrome_Websocket - Fatal编程技术网

Java 握手后Web套接字断开?

Java 握手后Web套接字断开?,java,google-chrome,websocket,Java,Google Chrome,Websocket,经过一些修改后,这是我的chrome客户端和java服务器之间的对话: GET / HTTP/1.1 Upgrade: websocket Connection: Upgrade Host: localhost:4444 Origin: chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo Pragma: no-cache Cache-Control: no-cache Sec-WebSocket-Key: Gh/WYxZXrUNZdPc2+LQ

经过一些修改后,这是我的chrome客户端和java服务器之间的对话:

GET / HTTP/1.1
Upgrade: websocket
Connection: Upgrade
Host: localhost:4444
Origin: chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo
Pragma: no-cache
Cache-Control: no-cache
Sec-WebSocket-Key: Gh/WYxZXrUNZdPc2+LQ/Tg==
Sec-WebSocket-Version: 13
Sec-WebSocket-Extensions: x-webkit-deflate-frame
Sent text to CLIENT_1
-------------Response to handshake------------
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: NmkE36ZEsC5baQaMjLPb5CxHwDM=
握手回复由以下人员给出:

public static String Key(String thekey) throws NoSuchAlgorithmException {
    String base64;

    thekey = thekey + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
    MessageDigest md = MessageDigest.getInstance("SHA-1");
    byte[] digest = md.digest(thekey.getBytes()); // Missing charset
    base64 = Base64.encodeBase64URLSafeString(digest);
    base64=base64.replace("_", "/");
    base64=base64.replace("-", "+");
    return new String(base64);
}
 Send("HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: " + Key(key) +"=\r\n\r\n");
然后我可以发送10字节的数据,然后客户端断开连接。 我能做什么? 提前谢谢! 斯莫列特