Community
Participate
Working Groups
Build Identifier: Please add a general purpose WebSocket client implementation to Jetty. My small list of requirements for WebSocket client implementation in Jetty: - the client WebSocket should support both ws and wss protocols. - it should be possible to send and receive arbitrary long binary messages. - when sending binary messages it should be possible to specify a byte array, the offset and the length (similar to what I can do today on the server: Connection#sendMessage(byte[], int, int)) Thanks in advance! Reproducible: Always
one working example: public class MySockWEB implements WebSocket, WebSocket.OnBinaryMessage, WebSocket.OnTextMessage{ .......................... public MySockWEB(String addr, int port) throws IOException { Socket socket = new Socket(addr, port); socket.setSoTimeout(6000); BufferedWriter output = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), "ISO-8859-1")); BufferedReader input = new BufferedReader(new InputStreamReader(socket.getInputStream(), "ISO-8859-1")); output.write("GET /test HTTP/1.1\r\nHost: localhost\r\nUpgrade: WebSocket\r\nConnection: Upgrade\r\n\r\n"); output.flush(); String responseLine = input.readLine(); // System.out.println(responseLine); if(!responseLine.startsWith("HTTP/1.1 101 Web Socket Protocol Handshake")){ throw new IOException("bad server response"); } String line; while ((line = input.readLine()) != null){ // System.out.println(line); if (line.length() == 0){ break; } } ep = new SocketEndPoint(socket); co = new WebSocketConnectionD00(this, ep, new WebSocketBuffers(32768), (long)0, 60000, ""); this.onOpen(((WebSocketConnectionD00)co)); new Thread(){ public void run(){ while (ep.isOpen()){ try { co.handle(); } catch (IOException e) { e.printStackTrace(); } Thread.sleep(1); } } }.start(); }
A websocket client has been added to jetty for the 7.5.0 release. http://webtide.intalio.com/2011/08/websocket-example-server-client-and-loadtest/
Resolved -> Closed