Hi Sergey, I added "socket.binaryType= 'arraybuffer';" but I get the same error. I'm not too sure if it is used or not as I don't know when WebSocket tries to connect, and setting socket.binaryType or socket.binarytype or socket.whatEver does not display any error.
Also, I'm wondering about the CXF configuration, is the binding to a separate server configured with a "ws://..." (the "ws" part) address mandatory? Regards, JP -----Message d'origine----- De : Sergey Beryozkin [mailto:[email protected]] Envoyé : mercredi 27 juillet 2016 12:34 À : [email protected] Objet : Re: Error during WebSocket handshake: Unexpected response code Hi On 27/07/16 12:26, CLEMENT Jean-Philippe wrote: > Dear CXF experts, > > I'm trying to connect a web client to a CXF WebSocket. The browser logs the > error "WebSocket connection failed: Error during WebSocket handshake: > Unexpected response code: XXX". The XXX response code changes depending on > the @Produces annotation: 200 when text/plain, 406 when text/*. > 406 with text/* can be explained by the fact the websocket client does not know what HTTP Accept is and the spec requires that when the final response type has a wildcard subtype (with the only exception being application/*) then it is 406. > The server Java looks like this: > @GET > @Path("monitor") > @Produces("text/*") > public StreamingOutput greetMonitor() { > return stream -> { > stream.write("Ok".getBytes()); > stream.flush(); > }; > } > > The client Javascript looks like this: > var socket= new > WebSocket("ws://myurlwithsameportaswebservice/cxf/test/monitor"); > > socket.onmessage= function(e) { console.log(e.data); }; > > What's wrong? Can you please look at https://github.com/apache/cxf/blob/master/distribution/src/main/release/samples/jax_rs/websocket/src/main/resources/index.html may be you need to set a socket type Cheers, Sergey > > Regards, > JP > -- Sergey Beryozkin Talend Community Coders http://coders.talend.com/
