jax_rs_websocket_osgi is the demo itself, you need to build it.
If you feel the whole CXF and Websockets/etc is new then perhaps you can
start with a websocket demo which I have built and confirmed is working,
test the actual WebSocket support, see if it works the way you expect it
and then finish off with making a websocket_osgi demo work.
websocket_osgi demo needs to be built manually - it won;t be in Central.
Download the appropriate CXF distribution - and build this demo inside
that distribution. Or checkout CXF master or 3.1.6 from GIT.
I've just built this demo in my 3.2.0-SNAPSHOT and it is avail in the
local Maven repo.
But may be it will be simpler to start from a 'plain' websockets demo.
Sergey
On 27/07/16 17:12, CLEMENT Jean-Philippe wrote:
Yes you are right. Also I'm a CXF and webstuff newbie which does not help :P
I made a clean installation of our Karaf assembly, then followed the readme.
The CXF 3.2.0-SNAPSHOT was not found, but the installation succeeded with the
3.1.6. Then the demo was not found (neither 3.1.6 nor 3.2.0):
install -s mvn:org.apache.cxf.samples/jax_rs_websocket_osgi/3.1.6
I was not able to find the jax_rs_websocket_osgi in maven central either. As a
fallback, I installed my test and went back to the client trace stating that
the WebSocket connection failed due to the unexpected response 501.
Maybe it is due to the CXF version 3.1.6 instead of 3.2.0-SNAPSHOT?
Regards,
JP
-----Message d'origine-----
De : Sergey Beryozkin [mailto:[email protected]]
Envoyé : mercredi 27 juillet 2016 15:46
À : [email protected]
Objet : Re: Error during WebSocket handshake: Unexpected response code
See may last email on the rel address and please do work with the demo first.
Sometimes users need to dive a bit into the details of a given demo :-)
Sergey
On 27/07/16 16:42, CLEMENT Jean-Philippe wrote:
I had to add cxf-http-jetty which is not described in the readme - I'm
not too sure this sample was tested on Karaf 4 (4.0.4)... now I'm
getting error 501 ... :D
JP
-----Message d'origine-----
De : Sergey Beryozkin [mailto:[email protected]] Envoyé : mercredi
27 juillet 2016 15:34 À : [email protected] Objet : Re: Error
during WebSocket handshake: Unexpected response code
Look at that demo and check README/etc, and make it work in Karaf.
I haven't written it but looks like it has all the info needed
Sergey
On 27/07/16 16:25, CLEMENT Jean-Philippe wrote:
Good, I went to
https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/websocket_osgi
and added the missing cxf-transports-websocket-server feature.
Things get better :) ... now I get NoClassDefFoundError:
org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.
Well, starting from a Karaf basic custom assembly, what features am I expected
to add as bootFeatures in order to get CXF+WebSockets running?
Regards,
JP
-----Message d'origine-----
De : Sergey Beryozkin [mailto:[email protected]] Envoyé : mercredi
27 juillet 2016 15:07 À : [email protected] Objet : Re: Error
during WebSocket handshake: Unexpected response code
Look at the websocket_osgi demo done by Aki
Sergey
On 27/07/16 15:55, CLEMENT Jean-Philippe wrote:
Haha, it seems I'm in the "servlet container mode" and not the "Jetty embedded
mode"... so I would have, as far as I understood, set both the address as a path and the
transportId to http://cxf.apache.org/transports/websocket.
I did try but I get the following exception:
BusException: No DestinationFactory was found for the namespace
http://cxf.apache.org/transports/websocket
What should I add to get rid of this exception?
Regards,
JP
-----Message d'origine-----
De : CLEMENT Jean-Philippe
[mailto:[email protected]]
Envoyé : mercredi 27 juillet 2016 14:44 À : [email protected]
Objet
: RE: Error during WebSocket handshake: Unexpected response code
I don't find the issue but something is strange; the /cxf page displays:
Endpoint address: http://localhost:8181/cxfws://localhost/socket
My blueprint is:
<jaxrs:server id="something" address="ws://localhost/socket">
The address parsing seems strange isn't it?
Regards,
JP
-----Message d'origine-----
De : Sergey Beryozkin [mailto:[email protected]] Envoyé :
mercredi
27 juillet 2016 14:35 À : [email protected] Objet : Re: Error
during WebSocket handshake: Unexpected response code
I've run a demo which Aki did and it works fine.
Yes make sure 'ws:' (or wss:) is used, it enables the loading of the
CXF WebSocket transport which can support both WebSocket and 'plain'
HTTP
Cheers, Sergey
On 27/07/16 13:49, CLEMENT Jean-Philippe wrote:
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/rel
e a s e/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/
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/