Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [kura-dev] Web Sockets using embedded Jetty

Hi Kevin,

I have never tried this particular setup, but I will help where I can. One thing to check would be the firewall. Kura will block ports unless specifically opened, so depending on what port you are using for Websocket, you could be getting blocked.

It may take a little time before I could setup this up myself. Do you have this running in a stand alone bundle you could share with me?

Thanks,
—Dave

On Nov 5, 2014, at 6:41 AM, Kevin Read <kevin.read@xxxxxxxxxxxxxxxxxx> wrote:

Dear all,

for our product we’d like to have real-time data updates pushed from the device over HTTP. To this end I’ve been trying out different solutions for server-sent data. The first was a Socket.IO server sitting on Netty [1], which always timed out without sending data. I switched to Atmosphere[2], which provides Websocket based communication with a fallback to HTTP long polling directly over the Servlet container.

Unfortunately this too doesn’t want to work correctly. The websocket upgrade never completes, leaving the client hanging. Here is the code I use to register with HTTPService:

mAtmoServlet = new AtmosphereDSServlet(mDataStore);
mHttpService.registerServlet("/chat", mAtmoServlet, null, null);
mAtmoServlet.init();

The servlet itself is just a thin wrapper registering handlers with the Atmosphere framework and setting the correct Websocket support:

public class AtmosphereDSServlet extends AtmosphereServlet {

private Datastore mDatastore;

protected static final Logger s_logger = LoggerFactory
.getLogger(AtmosphereDSServlet.class);

public AtmosphereDSServlet(final Datastore datastore) throws ServletException {
super();
mDatastore = datastore;
}

public void init() {
framework.addAtmosphereHandler("/chat", new ChatRoom());
framework.setAsyncSupport(new JettyServlet30AsyncSupportWithWebSocket(framework.getAtmosphereConfig()));
}
}

When the demo application wants to connect, it can load all the necessary JS from the HTTPService resources, but it can never complete the Websocket handshake. Debug log gives me this:

:37:37,841 [qtp809674942-24 - /app/js/index.js] DEBUG ContextHandler:993  - context=||/app/js/index.js @ o.e.j.s.ServletContextHandler{/,null}
15:37:37,844 [qtp809674942-24 - /app/js/index.js] DEBUG session:275  - Got Session ID 1h35mxzrwp74s1bk2nsh58qtp8 from cookie
15:37:37,844 [qtp809674942-24 - /app/js/index.js] DEBUG session:186  - sessionManager=org.eclipse.jetty.server.session.HashSessionManager@4335ed52
15:37:37,844 [qtp809674942-24 - /app/js/index.js] DEBUG session:187  - session=null
15:37:37,844 [qtp809674942-24 - /app/js/index.js] DEBUG ServletHandler:399  - servlet ||/app/js/index.js -> org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet-2054775530
15:37:37,844 [qtp809674942-24 - /app/js/index.js] DEBUG ServletHandler:461  - chain=null
15:37:37,847 [qtp809674942-24 - /app/js/index.js] INFO  BasicHttpContext:28  - security path null
15:37:37,847 [qtp809674942-24 - /app/js/index.js] INFO  BasicHttpContext:35  - resource path static/js/index.js
15:37:37,848 [qtp809674942-24 - /app/js/index.js] DEBUG Server:347  - RESPONSE /app/js/index.js  304
15:37:37,849 [qtp809674942-24] DEBUG AsyncHttpConnection:206  - Enabled read interest SCEP@1358f1fa{l(/0:0:0:0:0:0:0:1:58697)<->r(/0:0:0:0:0:0:0:1:8080),d=true,open=true,ishut=false,oshut=false,rb=false,wb=false,w=true,i=1r}-{AsyncHttpConnection@4715f036,g=HttpGenerator{s=4,h=0,b=-1,c=-1},p=HttpParser{s=0,l=29,c=0},r=1}
15:37:37,851 [qtp809674942-24] DEBUG HttpParser:276  - filled 0/0
15:37:37,903 [qtp809674942-18 Selector0] DEBUG nio:837  - created SCEP@580930a4{l(/0:0:0:0:0:0:0:1:58703)<->r(/0:0:0:0:0:0:0:1:8080),d=false,open=true,ishut=false,oshut=false,rb=false,wb=false,w=true,i=0}-{AsyncHttpConnection@43588c23,g=HttpGenerator{s=0,h=-1,b=-1,c=-1},p=HttpParser{s=-14,l=0,c=0},r=0}
15:37:37,904 [qtp809674942-21] DEBUG HttpParser:276  - filled 795/795
15:37:37,904 [qtp809674942-21 - /chat/?X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=2.2.6-_javascript_&X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&Content-Type=application/json&X-atmo-protocol=true] DEBUG Server:345  - REQUEST /chat/ on AsyncHttpConnection@43588c23,g=HttpGenerator{s=0,h=-1,b=-1,c=-1},p=HttpParser{s=-5,l=42,c=0},r=1
15:37:37,905 [qtp809674942-21 - /chat/?X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=2.2.6-_javascript_&X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&Content-Type=application/json&X-atmo-protocol=true] DEBUG ContextHandler:921  - scope null||/chat/ @ o.e.j.s.ServletContextHandler{/,null}
15:37:37,905 [qtp809674942-21 - /chat/?X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=2.2.6-_javascript_&X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&Content-Type=application/json&X-atmo-protocol=true] DEBUG ContextHandler:993  - context=||/chat/ @ o.e.j.s.ServletContextHandler{/,null}
15:37:37,905 [qtp809674942-21 - /chat/?X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=2.2.6-_javascript_&X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&Content-Type=application/json&X-atmo-protocol=true] DEBUG session:275  - Got Session ID 1h35mxzrwp74s1bk2nsh58qtp8 from cookie
15:37:37,905 [qtp809674942-21 - /chat/?X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=2.2.6-_javascript_&X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&Content-Type=application/json&X-atmo-protocol=true] DEBUG session:186  - sessionManager=org.eclipse.jetty.server.session.HashSessionManager@4335ed52
15:37:37,905 [qtp809674942-21 - /chat/?X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=2.2.6-_javascript_&X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&Content-Type=application/json&X-atmo-protocol=true] DEBUG session:187  - session=null
15:37:37,905 [qtp809674942-21 - /chat/?X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=2.2.6-_javascript_&X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&Content-Type=application/json&X-atmo-protocol=true] DEBUG ServletHandler:399  - servlet ||/chat/ -> org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet-2054775530
15:37:37,905 [qtp809674942-21 - /chat/?X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=2.2.6-_javascript_&X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&Content-Type=application/json&X-atmo-protocol=true] DEBUG ServletHandler:461  - chain=null
15:37:37,920 [qtp809674942-21 - /chat/?X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=2.2.6-_javascript_&X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&Content-Type=application/json&X-atmo-protocol=true] DEBUG WebSocketFactory:395  - extensions=[]
15:37:37,946 [qtp809674942-21 - /chat/?X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=2.2.6-_javascript_&X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&Content-Type=application/json&X-atmo-protocol=true] DEBUG WebSocketFactory:296  - Websocket upgrade /chat/ 13 null WebSocketServletConnectionRFC6455 p=WebSocketParserRFC6455@4b14cf96 state=START buffer=null g=WebSocketGeneratorRFC6455@4348a75c closed=false buffer=-1
15:37:37,946 [qtp809674942-21 - /chat/?X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=2.2.6-_javascript_&X-Atmosphere-Transport=websocket&X-Atmosphere-TrackMessageSize=true&Content-Type=application/json&X-atmo-protocol=true] DEBUG Server:347  - RESPONSE /chat/  101
15:37:37,947 [qtp809674942-21] DEBUG AsyncHttpConnection:206  - Enabled read interest SCEP@580930a4{l(/0:0:0:0:0:0:0:1:58703)<->r(/0:0:0:0:0:0:0:1:8080),d=true,open=true,ishut=false,oshut=false,rb=false,wb=false,w=true,i=0r}-{AsyncHttpConnection@43588c23,g=HttpGenerator{s=4,h=0,b=-1,c=-1},p=HttpParser{s=0,l=42,c=0},r=1}
15:37:37,948 [qtp809674942-21] DEBUG nio:609  - WebSocketServletConnectionRFC6455 p=WebSocketParserRFC6455@4b14cf96 state=START buffer=null g=WebSocketGeneratorRFC6455@4348a75c closed=false buffer=-1 replaced AsyncHttpConnection@43588c23,g=HttpGenerator{s=0,h=-1,b=-1,c=-1},p=HttpParser{s=-14,l=0,c=-3},r=1
15:37:37,993 [qtp809674942-24] DEBUG HttpParser:276  - filled 395/395

I tried getting support from the Atmosphere guys but they could not give me any pointers. I found no related issues on the issue tracker and Jetty 8.1 seems well supported. I’d be glad for any pointers.

Thanks and all the best,
Kevin

_______________________________________________
kura-dev mailing list
kura-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/kura-dev


Back to the top