You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Nick Baker <nb...@pentaho.com> on 2016/04/04 21:40:34 UTC
Working WebSocket example?
Hey All,
Does anyone have a working project using WebSockets? I was trying a quick prototype repurposing the CXF example but haven't had any luck:
https://github.com/apache/cxf/blob/master/distribution/src/main/release/samples/jax_rs/websocket/src/main/java/demo/jaxrs/server/CustomerService.java
I keep receiving a 200 from the server, whereas 101 should be returned:
[Error] WebSocket connection to 'ws://localhost:8181/cxf/sockets/infinitymachine/clock' failed: Unexpected response code: 200
Thanks,
Nick
Re: Working WebSocket example?
Posted by Nick Baker <nb...@pentaho.com>.
Thanks All!
Turned out I was missing the transportId="http://cxf.apache.org/transports/websocket" attribute on the <jaxrs:server> tag. I'm now getting a WebSocket created on the client and it is receiving events from the server. Unfortunately, the messages are all "\r\nX".
This is encouraging though. I'll keep going and keep you all posted.
-Nick
From: Aki Yoshida <el...@gmail.com>>
Reply-To: "user@karaf.apache.org<ma...@karaf.apache.org>" <us...@karaf.apache.org>>
Date: Tuesday, April 5, 2016 at 5:11 AM
To: "user@karaf.apache.org<ma...@karaf.apache.org>" <us...@karaf.apache.org>>
Subject: Re: Working WebSocket example?
Hi,
I have just added an osgi (blueprint) version of that cxf websocket sample to cxf's sample distribution. It should work on both karat 3.0.x and 4.0.x out of the box.
https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/websocket_osgi
There is also a node.js client included in this sample to test this cxf service using websocket and SSE.
2016-04-04 21:40 GMT+02:00 Nick Baker <nb...@pentaho.com>>:
Hey All,
Does anyone have a working project using WebSockets? I was trying a quick prototype repurposing the CXF example but haven't had any luck:
https://github.com/apache/cxf/blob/master/distribution/src/main/release/samples/jax_rs/websocket/src/main/java/demo/jaxrs/server/CustomerService.java
I keep receiving a 200 from the server, whereas 101 should be returned:
[Error] WebSocket connection to 'ws://localhost:8181/cxf/sockets/infinitymachine/clock' failed: Unexpected response code: 200
Thanks,
Nick
Re: Working WebSocket example?
Posted by Aki Yoshida <el...@gmail.com>.
Hi,
I have just added an osgi (blueprint) version of that cxf websocket sample
to cxf's sample distribution. It should work on both karat 3.0.x and 4.0.x
out of the box.
https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/websocket_osgi
There is also a node.js client included in this sample to test this cxf
service using websocket and SSE.
2016-04-04 21:40 GMT+02:00 Nick Baker <nb...@pentaho.com>:
> Hey All,
>
> Does anyone have a working project using WebSockets? I was trying a quick
> prototype repurposing the CXF example but haven't had any luck:
>
>
> https://github.com/apache/cxf/blob/master/distribution/src/main/release/samples/jax_rs/websocket/src/main/java/demo/jaxrs/server/CustomerService.java
>
>
> I keep receiving a 200 from the server, whereas 101 should be returned:
>
> [Error] WebSocket connection to
> 'ws://localhost:8181/cxf/sockets/infinitymachine/clock' failed: Unexpected
> response code: 200
>
> Thanks,
> Nick
>
Re: Working WebSocket example?
Posted by Tom Barber <to...@meteorite.bi>.
A while ago me and Achim tried websockets with CXF, it failed miserably, so
I also swapped to PAX Web. Clearly not to say it doesn't work, but there
were a bunch of "oh we're so close, but its not working" moments....
On Mon, Apr 4, 2016 at 11:13 PM, Nick Baker <nb...@pentaho.com> wrote:
> Thanks Achim,
>
> This is interesting. I should have mentioned that we're using the CXF
> features from Karaf 4.0.3 and Blueprint XML. We're unfortunately not able
> to leverage WAB capabilities.
>
> -Nick
>
> From: Achim Nierbeck <bc...@googlemail.com>
> Reply-To: "user@karaf.apache.org" <us...@karaf.apache.org>
> Date: Monday, April 4, 2016 at 3:47 PM
> To: "user@karaf.apache.org" <us...@karaf.apache.org>
> Subject: Re: Working WebSocket example?
>
> Hi,
>
> might want to take a look at this one [1].
> It should work right away with K4 and Pax-Web 4.2.x
>
> regards, Achim
>
> [1] -
> https://github.com/ops4j/org.ops4j.pax.web/tree/pax-web-4.2.x/samples/websocket-jsr356
>
>
> 2016-04-04 21:40 GMT+02:00 Nick Baker <nb...@pentaho.com>:
>
>> Hey All,
>>
>> Does anyone have a working project using WebSockets? I was trying a quick
>> prototype repurposing the CXF example but haven't had any luck:
>>
>>
>> https://github.com/apache/cxf/blob/master/distribution/src/main/release/samples/jax_rs/websocket/src/main/java/demo/jaxrs/server/CustomerService.java
>>
>>
>> I keep receiving a 200 from the server, whereas 101 should be returned:
>>
>> [Error] WebSocket connection to
>> 'ws://localhost:8181/cxf/sockets/infinitymachine/clock' failed: Unexpected
>> response code: 200
>>
>> Thanks,
>> Nick
>>
>
>
>
> --
>
> Apache Member
> Apache Karaf <http://karaf.apache.org/> Committer & PMC
> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
> Project Lead
> blog <http://notizblog.nierbeck.de/>
> Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>
>
> Software Architect / Project Manager / Scrum Master
>
>
Re: Working WebSocket example?
Posted by Nick Baker <nb...@pentaho.com>.
Thanks Achim,
This is interesting. I should have mentioned that we're using the CXF features from Karaf 4.0.3 and Blueprint XML. We're unfortunately not able to leverage WAB capabilities.
-Nick
From: Achim Nierbeck <bc...@googlemail.com>>
Reply-To: "user@karaf.apache.org<ma...@karaf.apache.org>" <us...@karaf.apache.org>>
Date: Monday, April 4, 2016 at 3:47 PM
To: "user@karaf.apache.org<ma...@karaf.apache.org>" <us...@karaf.apache.org>>
Subject: Re: Working WebSocket example?
Hi,
might want to take a look at this one [1].
It should work right away with K4 and Pax-Web 4.2.x
regards, Achim
[1] - https://github.com/ops4j/org.ops4j.pax.web/tree/pax-web-4.2.x/samples/websocket-jsr356
2016-04-04 21:40 GMT+02:00 Nick Baker <nb...@pentaho.com>>:
Hey All,
Does anyone have a working project using WebSockets? I was trying a quick prototype repurposing the CXF example but haven't had any luck:
https://github.com/apache/cxf/blob/master/distribution/src/main/release/samples/jax_rs/websocket/src/main/java/demo/jaxrs/server/CustomerService.java
I keep receiving a 200 from the server, whereas 101 should be returned:
[Error] WebSocket connection to 'ws://localhost:8181/cxf/sockets/infinitymachine/clock' failed: Unexpected response code: 200
Thanks,
Nick
--
Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>
Software Architect / Project Manager / Scrum Master
Re: Working WebSocket example?
Posted by Achim Nierbeck <bc...@googlemail.com>.
Hi,
might want to take a look at this one [1].
It should work right away with K4 and Pax-Web 4.2.x
regards, Achim
[1] -
https://github.com/ops4j/org.ops4j.pax.web/tree/pax-web-4.2.x/samples/websocket-jsr356
2016-04-04 21:40 GMT+02:00 Nick Baker <nb...@pentaho.com>:
> Hey All,
>
> Does anyone have a working project using WebSockets? I was trying a quick
> prototype repurposing the CXF example but haven't had any luck:
>
>
> https://github.com/apache/cxf/blob/master/distribution/src/main/release/samples/jax_rs/websocket/src/main/java/demo/jaxrs/server/CustomerService.java
>
>
> I keep receiving a 200 from the server, whereas 101 should be returned:
>
> [Error] WebSocket connection to
> 'ws://localhost:8181/cxf/sockets/infinitymachine/clock' failed: Unexpected
> response code: 200
>
> Thanks,
> Nick
>
--
Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>
Software Architect / Project Manager / Scrum Master
Re: Working WebSocket example?
Posted by Vincent Zurczak <vi...@linagora.com>.
Hi,
You can also take a look at this implementation [0].
We manually register a web socket servlet in the OSGi service [1] [2].
It is a little more complicated that just an example.
The reason is that we need to inject iPojo components in our web sockets.
But anyway, it may help. BTW, it works with Karaf 4 (since we need a
recent version of Jetty).
Regards,
Vincent.
[ 0 ] :
https://github.com/roboconf/roboconf-platform/tree/master/core/roboconf-dm-rest-services
[ 1 ] :
https://github.com/roboconf/roboconf-platform/tree/master/core/roboconf-dm-rest-services/src/main/java/net/roboconf/dm/rest/services/internal/websocket
[ 2 ] :
https://github.com/roboconf/roboconf-platform/blob/master/core/roboconf-dm-rest-services/src/main/java/net/roboconf/dm/rest/services/internal/ServletRegistrationComponent.java
Le 04/04/2016 21:40, Nick Baker a écrit :
> Hey All,
>
> Does anyone have a working project using WebSockets? I was trying a
> quick prototype repurposing the CXF example but haven't had any luck:
>
> https://github.com/apache/cxf/blob/master/distribution/src/main/release/samples/jax_rs/websocket/src/main/java/demo/jaxrs/server/CustomerService.java
>
>
> I keep receiving a 200 from the server, whereas 101 should be returned:
>
> [Error] WebSocket connection to
> 'ws://localhost:8181/cxf/sockets/infinitymachine/clock' failed:
> Unexpected response code: 200
>
> Thanks,
> Nick
--
Vincent Zurczak
Linagora: www.linagora.com <http://www.linagora.com/>
Twitter <https://twitter.com/VincentZurczak> Vincent Zurczak @ LinkedIn
<http://fr.linkedin.com/pub/vincent-zurczak/18/b35/6a7> My Skype ID
<callto://vincent.zurczak> My English blog <http://vzurczak.wordpress.com>