Long Polling fallback with websocket spring initialization
I am using Spring annotations to initialize my BayeuxServer. I enabled websocket by setting the transport in my Spring bean -
BayeuxServerImpl bean = new BayeuxServerImpl(); bean.setTransports(new WebSocketTransport(bean));
But now, when websocket connection fails or is disabled in js($.cometd.websocketEnabled = false;), it's not falling back to long polling successfully. It throws error "400 Unknown Bayeux Transport" in firebug console.
I couldn't set LongPollingTransport in setTransports since LongPollingTransport is an abstract class in the library. I tried creating a class which extends LongPollingTransport and specifying it in the setTransports API, but that didn't work either. Please let me know if I am doing something wrong. We need long polling to work in case websockets fail.
cometd version: 2.5.1
jetty version: 7.6.8
By calling BayeuxServer.setTransports(...) with just one transport, you basically disable any fall back capability since you are explicitly telling CometD to use 1 transport only.
Class LongPollingTransport has 2 subclasses depending on the specific mechanism to use; you may want to use class JSONTransport.
Basically, it all boils down to:
bayeuxServer.setTransports(new WebSocketTransport(bayeuxServer), new JSONTransport(bayeuxServer));