You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Alexander Broekhuis <a....@gmail.com> on 2015/03/30 11:01:45 UTC

WebSockets usage

Hi all,

I'm trying to use the HTTP bundles to setup some websockets. For my example
I've created an implementation of the abstract WebSocketServlet which only
has a configure method implemented.
This "configure" method has a WebSocketServletFactory as only argument,
which is used to register a WebSocket.

public class MyWebSocketServlet extends WebSocketServlet {
    @Override
    public void configure(WebSocketServletFactory arg0) {
        arg0.register(MyWebSocket.class);
    }
}

The WebSocket has one method and uses annotations to mark it as a Socket
with a Message.

@WebSocket
public class MyWebSocket {
    @OnWebSocketMessage
    public void onText(Session session, String message) {
        if (session.isOpen()) {
            System.out.printf("Echoing back message [%s]%n", message);
            session.getRemote().sendString(message, null);
        }
    }
}

I've tried registering this servlet using the whiteboard handler, as well
as directly to the http service. In both scenarios I run in a
ClassNotFoundException for the WebSocketServletFactory.

What am I doing wrong? How am I supposed to use websockets with the http
bundles (preferably using the whiteboard pattern).

The same question has also been asked on stackoverflow [1], but no answer
is given, although there is a pointer to the underlying issue.

[1]:
http://stackoverflow.com/questions/29099699/osgi-bundle-in-felix-classnotfoundexception-for-jetty-class-loaded-by-name

Thanks in advance,

-- 
Met vriendelijke groet,

Alexander Broekhuis

Re: WebSockets usage

Posted by Alexander Broekhuis <a....@gmail.com>.
Hi Paul,

2015-03-30 11:17 GMT+02:00 Paul Bakker <pa...@luminis.eu>:

> Hi Alexander,
>
> It's not completely up to date (it was created before the release of Felix
> HTTP), but I have two examples on github:
> https://github.com/paulbakker/osgi-websockets-examples


Thanks, this gave me enough info to fix it. Setting the ContextClassloader
fixed the problem.


-- 
Met vriendelijke groet,

Alexander Broekhuis

Re: WebSockets usage

Posted by factor3 <rb...@bluebottle.com>.
Thanks, I found this out after discovering the .bnd files in the download. My
question was somewhat redundant. Apologies.

I do have another problem, though. I have created a project that has a
bundle that I want to use to call functions in the Websocket class. In other
words, I would like to be able to  (for example) send a connected client a
message by calling the MyEchoSocket's send method from another bundle (I am
using the Jetty example as my base).

My new project has duplicate the build and runtime dependencies, and I
imported the example Jetty example Java files into my project. 

I have been running the code in the debugger. I am seeing that the start()
method in the EchoServlet class is not being called. It is looking like the
servlet is not being loaded or registered with Jetty. 

I presume that these examples work by somehow registering the servlet with
Jetty, then letting Jetty (through the servlet) create MyEchoSocket
instances as needed. Unfortunately, it doesn't look at the registration of
the servlet is taking place.

Am I missing something? How do I make this servlet work?




--
View this message in context: http://apache-felix.18485.x6.nabble.com/WebSockets-usage-tp5012240p5015290.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: WebSockets usage

Posted by Thomas Driessen <th...@ds-lab.org>.
Hi,

I'm also currently diving into WebSockets and OSGi. I recognized, that the
jetty example of Paul Bakker is working with Chrome, but not with IE
(didn't test any other browsers). Did you try it in Chrome?
For the JSR example: the current distribution of jetty that comes with
felix.http doesn't contain the package org.eclipse.jetty.websocket.jsr356 which
is needed for the WebSocketServerContainerInitializer.

Kind regards,
Thomas

2015-10-26 12:53 GMT+01:00 factor3 <rb...@bluebottle.com>:

> Greetings, pkriens:
>
>    Your suggestion is an interesting one, and I will look into it for my
> immediate needs. I will, however, need to make Websockets work soon because
> some of the requirements for the application I am developing include a need
> to do 2- way communication between client and server in as close to
> realtime
> as possible. Websockets is the only solution that my peers/management will
> accept. It so happens that I agree that it is also the only viable solution
> for what we need to do.
>
>    As for my Websocket solution: I have been stepping through everything in
> the example as thoroughly as possible, and my initial assessment is
> correct:
> for some reason, the Jetty bundle is not "finding" the Echo servlet.
> Attempts to connect to the MyEchoSocket are failing, and I think they are
> failing because the code to register it is not being called. Everything
> appears to be the same as the example code -- which, by the way, is also
> failing.
>
> There has to be something in the environment or configuration that is
> missing or incorrect, but I am not finding it. Can someone please provide
> insights on how to get this thing to run properly???
>
>
>
>
> --
> View this message in context:
> http://apache-felix.18485.x6.nabble.com/WebSockets-usage-tp5012240p5015303.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 
M.Sc. Thomas Driessen
Software Methodologies for Distributed Systems
Institute of Computer Science
University of Augsburg
Universitätsstr. 6a
86135 Augsburg, Germany

Tel:    +49 821 598-2486
email: thomas.driessen@informatik.uni-augsburg.de

Re: WebSockets usage

Posted by Peter Kriens <pe...@aqute.biz>.
Why would web sockets be faster than Server Sent Events?

Kind regards,

	Peter Kriens

> On 26 okt. 2015, at 12:53, factor3 <rb...@bluebottle.com> wrote:
> 
> Greetings, pkriens:
> 
>   Your suggestion is an interesting one, and I will look into it for my
> immediate needs. I will, however, need to make Websockets work soon because
> some of the requirements for the application I am developing include a need
> to do 2- way communication between client and server in as close to realtime
> as possible. Websockets is the only solution that my peers/management will
> accept. It so happens that I agree that it is also the only viable solution
> for what we need to do.
> 
>   As for my Websocket solution: I have been stepping through everything in
> the example as thoroughly as possible, and my initial assessment is correct:
> for some reason, the Jetty bundle is not "finding" the Echo servlet.
> Attempts to connect to the MyEchoSocket are failing, and I think they are
> failing because the code to register it is not being called. Everything
> appears to be the same as the example code -- which, by the way, is also
> failing. 
> 
> There has to be something in the environment or configuration that is
> missing or incorrect, but I am not finding it. Can someone please provide
> insights on how to get this thing to run properly???
> 
> 
> 
> 
> --
> View this message in context: http://apache-felix.18485.x6.nabble.com/WebSockets-usage-tp5012240p5015303.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: WebSockets usage

Posted by factor3 <rb...@bluebottle.com>.
Greetings, Thomas:

   I grabbed your example and tested it in my development environment. It
failed to work -- until I added the Echo bundle to the list of runtime
bundles. Once I did that, everything worked without problems.

   Examining your code, I see that it is significantly different from Paul's
code. There are less required bundles (always a plus for me!) both in the
build and runtime .bnd files. 

   Thanks for sharing this example with me. I can now successfully use
Websockets. I expect some more difficulties (based on the fact that I will
be using them in some unusual ways!), but I don't expect them to be as big
as this one was.

Again, thanks...




--
View this message in context: http://apache-felix.18485.x6.nabble.com/WebSockets-usage-tp5012240p5015351.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: WebSockets usage

Posted by Thomas Driessen <th...@ds-lab.org>.
I checked my setup:
I adopted my setup to use the feli-scr annotations for declarative
services. Paul is using the felix dependecymanager annotations, which
require you to install an extra plugin in bnd-tools.
My Servlet is registered and so is the Websocket.
I attached the two adopted source files and the .bnd and .bndrun file.

In your .bnd file don't forget the line:
-dsannotations: *
I think this line is needed for the scr annotations to work properly.

Thomas


2015-10-26 21:50 GMT+01:00 Thomas Driessen <th...@ds-lab.org>:

> I'm currently at home and have no access to my code at work, but I will
> check all those things tomorrow at work :)
>
> Thomas
> Am 26.10.2015 20:27 schrieb "factor3" <rb...@bluebottle.com>:
>
>> Thomas:
>>
>> This is interesting, because I am using the Jetty solution.
>>
>> Is your servlet actually being registered? If it is, did you have to make
>> any changes in the code in order to achieve this?
>>
>> In particular, is that start() function in the servlet being called at any
>> time while you are running Felix? In my project, it is *not* being called,
>> so that direct registration is not happening. In other words, when I set
>> breakpoints in that function and run Felix in debug mode, the breakpoints
>> are never reached. Are you seeing the same thing when setting breakpoints
>> in
>> your start() function and runing Felix in the debugger? Or are your
>> breakpoints being reached? Are you able to connect to your Websocket
>> class?
>>
>>
>>
>> --
>> View this message in context:
>> http://apache-felix.18485.x6.nabble.com/WebSockets-usage-tp5012240p5015312.html
>> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>


-- 
M.Sc. Thomas Driessen
Software Methodologies for Distributed Systems
Institute of Computer Science
University of Augsburg
Universitätsstr. 6a
86135 Augsburg, Germany

Tel:    +49 821 598-2486
email: thomas.driessen@informatik.uni-augsburg.de

Re: WebSockets usage

Posted by Thomas Driessen <th...@ds-lab.org>.
I'm currently at home and have no access to my code at work, but I will
check all those things tomorrow at work :)

Thomas
Am 26.10.2015 20:27 schrieb "factor3" <rb...@bluebottle.com>:

> Thomas:
>
> This is interesting, because I am using the Jetty solution.
>
> Is your servlet actually being registered? If it is, did you have to make
> any changes in the code in order to achieve this?
>
> In particular, is that start() function in the servlet being called at any
> time while you are running Felix? In my project, it is *not* being called,
> so that direct registration is not happening. In other words, when I set
> breakpoints in that function and run Felix in debug mode, the breakpoints
> are never reached. Are you seeing the same thing when setting breakpoints
> in
> your start() function and runing Felix in the debugger? Or are your
> breakpoints being reached? Are you able to connect to your Websocket class?
>
>
>
> --
> View this message in context:
> http://apache-felix.18485.x6.nabble.com/WebSockets-usage-tp5012240p5015312.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

RE: WebSockets usage

Posted by Paulo Renato de Athaydes <re...@hotmail.com>.
I'm trying to get felix.http.jetty working but I faced several issues with the latest version of Felix.

First, the servlet-api bundle does not provide the JavaServlet capability. So I had to create a fragment saying that it does!

Then, after resolving all dependencies, I got this error below.

Any of you guys have faced this issue? Seems like a bug in Felix?!


Regards,

Renato


2015-10-27 23:32:16.846:WARN:oejuc.AbstractLifeCycle:FelixStartLevel: FAILED org.eclipse.jetty.server.Server@194bb959: java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) previously initiated loading for a different type with name "org/eclipse/jetty/util/component/LifeCycle$Listener"
java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) previously initiated loading for a different type with name "org/eclipse/jetty/util/component/LifeCycle$Listener"
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
        at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.defineClass(BundleWiringImpl.java:2370)
        at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.findClass(BundleWiringImpl.java:2154)
        at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1542)
g! ERROR: Bundle org.apache.felix.http.jetty [28] Error starting file:/home/renato/programming/java/osgi-run/osgi-run-test/declarative-services-demo/build/osgi/bundle/org.apache.felix.http.jetty-3.1.2.jar (org.osgi.framework.BundleException: Activator start error in bundle org.apache.felix.http.jetty [28].)
        at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79)
        at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2018)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.setStarting(AbstractLifeCycle.java:187)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:67)
        at org.apache.felix.http.jetty.internal.JettyService.initializeJetty(JettyService.java:269)
        at org.apache.felix.http.jetty.internal.JettyService.startJetty(JettyService.java:201)
        at org.apache.felix.http.jetty.internal.JettyService.start(JettyService.java:134)
        at org.apache.felix.http.jetty.internal.JettyActivator.doStart(JettyActivator.java:60)
        at org.apache.felix.http.base.internal.AbstractActivator.start(AbstractActivator.java:41)
        at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:697)
        at org.apache.felix.framework.Felix.activateBundle(Felix.java:2226)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:2144)
        at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1371)
        at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
        at java.lang.Thread.run(Thread.java:745)
java.lang.LinkageError: org/eclipse/jetty/util/component/LifeCycle$Listener
        at org.eclipse.jetty.util.component.AbstractLifeCycle.setFailed(AbstractLifeCycle.java:213)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
        at org.apache.felix.http.jetty.internal.JettyService.initializeJetty(JettyService.java:269)
        at org.apache.felix.http.jetty.internal.JettyService.startJetty(JettyService.java:201)
        at org.apache.felix.http.jetty.internal.JettyService.start(JettyService.java:134)
        at org.apache.felix.http.jetty.internal.JettyActivator.doStart(JettyActivator.java:60)
        at org.apache.felix.http.base.internal.AbstractActivator.start(AbstractActivator.java:41)
        at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:697)
        at org.apache.felix.framework.Felix.activateBundle(Felix.java:2226)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:2144)
        at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1371)
        at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)
        at java.lang.Thread.run(Thread.java:745)
ERROR: Cannot create MetaType providing ManagedService; not providing Metatype information but just accepting configuration
> Building 96% > :declarative-services-demo:runOsgilb 
START LEVEL 1
   ID|State      |Level|Name
    0|Active     |    0|System Bundle (5.4.0)
    1|Active     |    1|animal-sniffer-annotations (1.9.0)
    2|Active     |    1|Apache Commons FileUpload (1.3.1)
    3|Active     |    1|Commons IO (2.2.0)
    4|Active     |    1|components (1.0.0)
    5|Active     |    1|Guava: Google Core Libraries for Java (18.0.0)
    6|Active     |    1|Java Servlet API (3.1.0)
    7|Active     |    1|Jetty :: Http Utility (9.2.12.v20150709)
    8|Active     |    1|Jetty :: IO Utility (9.2.12.v20150709)
    9|Active     |    1|Jetty :: JMX Management (9.2.12.v20150709)
   10|Active     |    1|Jetty :: Security (9.2.12.v20150709)
   11|Active     |    1|Jetty :: Server Core (9.2.12.v20150709)
   12|Active     |    1|Jetty :: Servlet Handling (9.2.12.v20150709)
   13|Active     |    1|Jetty :: Utilities (9.2.12.v20150709)
   14|Active     |    1|Jetty :: Webapp Application Support (9.2.12.v20150709)
   15|Active     |    1|Jetty :: XML utilities (9.2.12.v20150709)
   16|Active     |    1|json (20150729.0.0)
   17|Active     |    1|jsr305 (3.0.0)
   18|Active     |    1|message-consumer (1.0.0)
   19|Active     |    1|message-producer (1.0.0)
   20|Active     |    1|messaging-api,Simple Messaging API (1.0.0)
   21|Active     |    1|Apache Felix Configuration Admin Service (1.8.8)
   22|Active     |    1|Apache Felix EventAdmin (1.4.4)
   23|Active     |    1|Apache Felix Gogo Command (0.14.0)
   24|Active     |    1|Apache Felix Gogo Runtime (0.12.1)
   25|Active     |    1|Apache Felix Gogo Shell (0.10.0)
   26|Active     |    1|Apache Felix Http API (3.0.0)
   27|Active     |    1|Apache Felix Http Base (3.0.2)
   28|Resolved   |    1|Apache Felix Http Jetty (3.1.2)
   29|Active     |    1|Apache Felix Declarative Services (2.0.2)
   30|Active     |    1|Apache Felix Web Management Console (4.2.14)
   31|Resolved   |    1|servlet-api-fragment (1.0.0)


> Date: Mon, 26 Oct 2015 12:19:04 -0700
> From: rbrown3@bluebottle.com
> To: users@felix.apache.org
> Subject: Re: WebSockets usage
> 
> Thomas:
> 
> This is interesting, because I am using the Jetty solution. 
> 
> Is your servlet actually being registered? If it is, did you have to make
> any changes in the code in order to achieve this?
> 
> In particular, is that start() function in the servlet being called at any
> time while you are running Felix? In my project, it is *not* being called,
> so that direct registration is not happening. In other words, when I set
> breakpoints in that function and run Felix in debug mode, the breakpoints
> are never reached. Are you seeing the same thing when setting breakpoints in
> your start() function and runing Felix in the debugger? Or are your
> breakpoints being reached? Are you able to connect to your Websocket class?
> 
> 
> 
> --
> View this message in context: http://apache-felix.18485.x6.nabble.com/WebSockets-usage-tp5012240p5015312.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 

 		 	   		  

Re: WebSockets usage

Posted by factor3 <rb...@bluebottle.com>.
Thomas:

This is interesting, because I am using the Jetty solution. 

Is your servlet actually being registered? If it is, did you have to make
any changes in the code in order to achieve this?

In particular, is that start() function in the servlet being called at any
time while you are running Felix? In my project, it is *not* being called,
so that direct registration is not happening. In other words, when I set
breakpoints in that function and run Felix in debug mode, the breakpoints
are never reached. Are you seeing the same thing when setting breakpoints in
your start() function and runing Felix in the debugger? Or are your
breakpoints being reached? Are you able to connect to your Websocket class?



--
View this message in context: http://apache-felix.18485.x6.nabble.com/WebSockets-usage-tp5012240p5015312.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: WebSockets usage

Posted by Thomas Driessen <th...@ds-lab.org>.
Hey,

unfortunately I don't know where to get a bundle with this package is
included. In my solution I desided to use the jetty specific solution.
Regarding the examples of Paul: At least in the jetty specific example he's
not using the whiteboard style, as he registers the servlet directly via
m_httpService... I think he is doing it this way because otherwise he
wouldn't have control over the used classloader.

Kind regards,
Thomas
Am 26.10.2015 19:26 schrieb "factor3" <rb...@bluebottle.com>:

> Jan and Thomas:
>
> Thanks for your responses.
>
> Answering Jan's questions: As for whiteboarding: included in the runtime
> dependencies is the bundle org.osgi.service.http.whiteboard, which I
> believe
> is the whiteboarding service you are referring to. I figured that it was
> whiteboarding being used because everything seems to be annotated and the
> whiteboarding bundle was included as a dependency. The bottom line: I
> believe I am using the whiteboarding bundle...
>
> Answering Thomas' questions:
>
>  I am using Firefox and Chrome, though the problem occurs regardless of the
> browser I use (note: I never use IE unless I absolutely have to, and I
> haven't had to for quite a while now!). The failure is not occurring in the
> browser. What is clear is that the servlet is not being registered.
> Consequently, the mechanisms for receiving a connection request from the
> client simply are not activated.
>
> One other matter: you mention a package missing from the latest Jetty
> bundle: org.eclipse.jetty.websocket.jsr356. I have confirmed that this is
> not in my Jetty bundle. Do you know where I can get a bundle with this
> package? My search for it seems to find plenty of descriptions of the
> WebSocketServerContainerInitializer class (lots of copies of the Javadoc)
> but I can't seem to find any bundles containing this package even on the
> Maven Repository. I'd like to see whether including it will make my
> application work. Do you know where I can get this package?
>
>
>
>
>
> --
> View this message in context:
> http://apache-felix.18485.x6.nabble.com/WebSockets-usage-tp5012240p5015310.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: WebSockets usage

Posted by factor3 <rb...@bluebottle.com>.
Jan and Thomas:

Thanks for your responses.

Answering Jan's questions: As for whiteboarding: included in the runtime
dependencies is the bundle org.osgi.service.http.whiteboard, which I believe
is the whiteboarding service you are referring to. I figured that it was
whiteboarding being used because everything seems to be annotated and the
whiteboarding bundle was included as a dependency. The bottom line: I
believe I am using the whiteboarding bundle...

Answering Thomas' questions: 

 I am using Firefox and Chrome, though the problem occurs regardless of the
browser I use (note: I never use IE unless I absolutely have to, and I
haven't had to for quite a while now!). The failure is not occurring in the
browser. What is clear is that the servlet is not being registered.
Consequently, the mechanisms for receiving a connection request from the
client simply are not activated.

One other matter: you mention a package missing from the latest Jetty
bundle: org.eclipse.jetty.websocket.jsr356. I have confirmed that this is
not in my Jetty bundle. Do you know where I can get a bundle with this
package? My search for it seems to find plenty of descriptions of the
WebSocketServerContainerInitializer class (lots of copies of the Javadoc)
but I can't seem to find any bundles containing this package even on the
Maven Repository. I'd like to see whether including it will make my
application work. Do you know where I can get this package?





--
View this message in context: http://apache-felix.18485.x6.nabble.com/WebSockets-usage-tp5012240p5015310.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: WebSockets usage

Posted by Thomas Driessen <th...@ds-lab.org>.
Just another thing I stumbled upon: Paul sets the IdleTimeout to 10 seconds
(factory.getPolicy().setIdleTimeout(10000);)
For me as a slow guy, this sometimes wasn't enough time to push the "send
msg" button and the connection was closed before ;)



2015-10-26 13:21 GMT+01:00 Jan Willem Janssen <ja...@luminis.eu>
:

> Hi,
>
> How are you registering your servlet? I've not looked at the repository of
> Paul, but I think he's using the whiteboard approach for registering his
> servlets.
> Is the http whiteboard bundle present in your run configuration?
>
> Hth,
>   Jan Willem
>
> On 26 Oct 2015 13:02, factor3 <rb...@bluebottle.com> wrote:
> Greetings, pkriens:
>
>    Your suggestion is an interesting one, and I will look into it for my
> immediate needs. I will, however, need to make Websockets work soon because
> some of the requirements for the application I am developing include a need
> to do 2- way communication between client and server in as close to
> realtime
> as possible. Websockets is the only solution that my peers/management will
> accept. It so happens that I agree that it is also the only viable solution
> for what we need to do.
>
>    As for my Websocket solution: I have been stepping through everything in
> the example as thoroughly as possible, and my initial assessment is
> correct:
> for some reason, the Jetty bundle is not "finding" the Echo servlet.
> Attempts to connect to the MyEchoSocket are failing, and I think they are
> failing because the code to register it is not being called. Everything
> appears to be the same as the example code -- which, by the way, is also
> failing.
>
> There has to be something in the environment or configuration that is
> missing or incorrect, but I am not finding it. Can someone please provide
> insights on how to get this thing to run properly???
>
>
>
>
> --
> View this message in context:
> http://apache-felix.18485.x6.nabble.com/WebSockets-usage-tp5012240p5015303.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 
M.Sc. Thomas Driessen
Software Methodologies for Distributed Systems
Institute of Computer Science
University of Augsburg
Universitätsstr. 6a
86135 Augsburg, Germany

Tel:    +49 821 598-2486
email: thomas.driessen@informatik.uni-augsburg.de

Re: WebSockets usage

Posted by Jan Willem Janssen <ja...@luminis.eu>.
Hi,

How are you registering your servlet? I've not looked at the repository of Paul, but I think he's using the whiteboard approach for registering his servlets.
Is the http whiteboard bundle present in your run configuration?

Hth,
  Jan Willem

On 26 Oct 2015 13:02, factor3 <rb...@bluebottle.com> wrote:
Greetings, pkriens:

   Your suggestion is an interesting one, and I will look into it for my
immediate needs. I will, however, need to make Websockets work soon because
some of the requirements for the application I am developing include a need
to do 2- way communication between client and server in as close to realtime
as possible. Websockets is the only solution that my peers/management will
accept. It so happens that I agree that it is also the only viable solution
for what we need to do.

   As for my Websocket solution: I have been stepping through everything in
the example as thoroughly as possible, and my initial assessment is correct:
for some reason, the Jetty bundle is not "finding" the Echo servlet.
Attempts to connect to the MyEchoSocket are failing, and I think they are
failing because the code to register it is not being called. Everything
appears to be the same as the example code -- which, by the way, is also
failing.

There has to be something in the environment or configuration that is
missing or incorrect, but I am not finding it. Can someone please provide
insights on how to get this thing to run properly???




--
View this message in context: http://apache-felix.18485.x6.nabble.com/WebSockets-usage-tp5012240p5015303.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: WebSockets usage

Posted by factor3 <rb...@bluebottle.com>.
Greetings, pkriens:

   Your suggestion is an interesting one, and I will look into it for my
immediate needs. I will, however, need to make Websockets work soon because
some of the requirements for the application I am developing include a need
to do 2- way communication between client and server in as close to realtime
as possible. Websockets is the only solution that my peers/management will
accept. It so happens that I agree that it is also the only viable solution
for what we need to do.

   As for my Websocket solution: I have been stepping through everything in
the example as thoroughly as possible, and my initial assessment is correct:
for some reason, the Jetty bundle is not "finding" the Echo servlet.
Attempts to connect to the MyEchoSocket are failing, and I think they are
failing because the code to register it is not being called. Everything
appears to be the same as the example code -- which, by the way, is also
failing. 

There has to be something in the environment or configuration that is
missing or incorrect, but I am not finding it. Can someone please provide
insights on how to get this thing to run properly???




--
View this message in context: http://apache-felix.18485.x6.nabble.com/WebSockets-usage-tp5012240p5015303.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: WebSockets usage

Posted by Peter Kriens <pe...@aqute.biz>.
I am not sure how hard your requirements are on websockets. I’ve got very good experiences with the Server Sent Events. They are trivially to implement with a Servlet and extremely well supported in the browser.

In OSGi enRoute they are part of the core API & distribution. It uses Event Admin to broadcast messages to the browser. It is describes in  http://enroute.osgi.org/services/osgi.enroute.easse.html <http://enroute.osgi.org/services/osgi.enroute.easse.html> and you can look at an example in https://github.com/osgi/osgi.enroute.examples/tree/master/osgi.enroute.examples.scheduler.application <https://github.com/osgi/osgi.enroute.examples/tree/master/osgi.enroute.examples.scheduler.application> (most examples in this repo use the Server Sent Events to update the GUI in real time).

Kind regards,

	Peter Kriens


> On 25 okt. 2015, at 16:38, Alexander Broekhuis <a....@gmail.com> wrote:
> 
> Hi,
> 
> If you pull Paul's repo [1], you get a complete BndTools workspace,
> including all dependencies. Inside the projects there are also bndrun files
> to run the demo [2]. You can also use those files to see what dependencies
> are used.
> 
> Hth!
> 
> 
> [1]: https://github.com/paulbakker/osgi-websockets-examples
> [2]:
> https://github.com/paulbakker/osgi-websockets-examples/blob/master/jetty-websockets/demo.bndrun
> 
> 2015-10-24 4:41 GMT+02:00 factor3 <rb...@bluebottle.com>:
> 
>> I have been looking at your Websocket examples with great interest. I would
>> lie to run them in my own Felix container. One problem, though: what are
>> the
>> dependent bundles necessary to run these examples, and where do I find
>> them?
>> 
>> 
>> 
>> 
>> 
>> --
>> View this message in context:
>> http://apache-felix.18485.x6.nabble.com/WebSockets-usage-tp5012240p5015251.html
>> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>> 
>> 
> 
> 
> -- 
> Met vriendelijke groet,
> 
> Alexander Broekhuis


Re: WebSockets usage

Posted by Alexander Broekhuis <a....@gmail.com>.
Hi,

If you pull Paul's repo [1], you get a complete BndTools workspace,
including all dependencies. Inside the projects there are also bndrun files
to run the demo [2]. You can also use those files to see what dependencies
are used.

Hth!


[1]: https://github.com/paulbakker/osgi-websockets-examples
[2]:
https://github.com/paulbakker/osgi-websockets-examples/blob/master/jetty-websockets/demo.bndrun

2015-10-24 4:41 GMT+02:00 factor3 <rb...@bluebottle.com>:

> I have been looking at your Websocket examples with great interest. I would
> lie to run them in my own Felix container. One problem, though: what are
> the
> dependent bundles necessary to run these examples, and where do I find
> them?
>
>
>
>
>
> --
> View this message in context:
> http://apache-felix.18485.x6.nabble.com/WebSockets-usage-tp5012240p5015251.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 
Met vriendelijke groet,

Alexander Broekhuis

Re: WebSockets usage

Posted by factor3 <rb...@bluebottle.com>.
I have been looking at your Websocket examples with great interest. I would
lie to run them in my own Felix container. One problem, though: what are the
dependent bundles necessary to run these examples, and where do I find them?

 



--
View this message in context: http://apache-felix.18485.x6.nabble.com/WebSockets-usage-tp5012240p5015251.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: WebSockets usage

Posted by Paul Bakker <pa...@luminis.eu>.
Hi Alexander,

It's not completely up to date (it was created before the release of Felix
HTTP), but I have two examples on github:
https://github.com/paulbakker/osgi-websockets-examples

Cheers,

Paul

On Mon, Mar 30, 2015 at 11:03 AM Alexander Broekhuis <a....@gmail.com>
wrote:

> Hi all,
>
> I'm trying to use the HTTP bundles to setup some websockets. For my example
> I've created an implementation of the abstract WebSocketServlet which only
> has a configure method implemented.
> This "configure" method has a WebSocketServletFactory as only argument,
> which is used to register a WebSocket.
>
> public class MyWebSocketServlet extends WebSocketServlet {
>     @Override
>     public void configure(WebSocketServletFactory arg0) {
>         arg0.register(MyWebSocket.class);
>     }
> }
>
> The WebSocket has one method and uses annotations to mark it as a Socket
> with a Message.
>
> @WebSocket
> public class MyWebSocket {
>     @OnWebSocketMessage
>     public void onText(Session session, String message) {
>         if (session.isOpen()) {
>             System.out.printf("Echoing back message [%s]%n", message);
>             session.getRemote().sendString(message, null);
>         }
>     }
> }
>
> I've tried registering this servlet using the whiteboard handler, as well
> as directly to the http service. In both scenarios I run in a
> ClassNotFoundException for the WebSocketServletFactory.
>
> What am I doing wrong? How am I supposed to use websockets with the http
> bundles (preferably using the whiteboard pattern).
>
> The same question has also been asked on stackoverflow [1], but no answer
> is given, although there is a pointer to the underlying issue.
>
> [1]:
> http://stackoverflow.com/questions/29099699/osgi-bundle-in-felix-
> classnotfoundexception-for-jetty-class-loaded-by-name
>
> Thanks in advance,
>
> --
> Met vriendelijke groet,
>
> Alexander Broekhuis
>