2015-03-10 1 views
1

Existe-t-il un exemple d'utilisation du composant Apache Camel Atmosphere Websocket (atmosphere-websocket)? J'essaie une chose de base; envoyer le message du client (Html5 Websocket) au grave (composant Camel atmosphère-webscoket) et renvoyer au client. Le grave que j'utilise est vFabric tc Runtime 2.9.5.SR1 ou Tomcat 7.0.50Exemple d'utilisation du composant Websocket Apache Camel Atmosphere

Mon Route ressemble à ce

from("atmosphere-websocket://localhost:8181/test1").to("log:body ${body}").to("atmosphere-websocket://localhost:8181/test1"); 

code Javascript

var ws = new WebSocket("ws://localhost:8181/test1");  
ws.onopen = function (e) {  
    console.log("open"); 
} 
ws.onclose = function (e) {  
    console.log("close"); 
} 
ws.onerror = function (e) {  
    console.log("error"); 
} 
ws.onmessage = function (e) {   
    console.log("message"); 
} 

Mais je reçois une erreur

WebSocket connection to 'ws://localhost:8181/test1' failed: Error during WebSocket handshake: Unexpected response code: 403 

à partir du journal que je peux voir que la route et le cadre Atmospher commencé sans aucune erreur

2015-03-10 16:13:14,391 [ost-startStop-1] WARN IOUtils      - META-INF/services/org.atmosphere.cpr.AtmosphereFramework not found in class loader 

2015-03-10 16:13:14,435 [ost-startStop-1] INFO AtmosphereFramework   - Atmosphere is using org.atmosphere.cpr.DefaultAnnotationProcessor for processing annotation 

2015-03-10 16:13:14,436 [ost-startStop-1] INFO DefaultAnnotationProcessor  - AnnotationProcessor class org.atmosphere.cpr.DefaultAnnotationProcessor$BytecodeBasedAnnotationProcessor being used 

2015-03-10 16:13:14,482 [ost-startStop-1] INFO AtmosphereFramework   - Auto detecting atmosphere handlers /WEB-INF/classes/ 

2015-03-10 16:13:14,484 [ost-startStop-1] INFO AtmosphereFramework   - Auto detecting WebSocketHandler in /WEB-INF/classes/ 

2015-03-10 16:13:14,485 [ost-startStop-1] INFO AtmosphereFramework   - Installed WebSocketProtocol org.apache.camel.component.atmosphere.websocket.WebsocketHandler 

2015-03-10 16:13:14,516 [ost-startStop-1] INFO AtmosphereFramework   - Installed AtmosphereHandler org.atmosphere.cpr.AtmosphereFramework$5 mapped to context-path: /* 

2015-03-10 16:13:14,516 [ost-startStop-1] INFO AtmosphereFramework   - Installed the following AtmosphereInterceptor mapped to AtmosphereHandler org.atmosphere.cpr.AtmosphereFramework$5 

2015-03-10 16:13:14,516 [ost-startStop-1] INFO AtmosphereFramework   - Installing Default AtmosphereInterceptor 

2015-03-10 16:13:14,517 [ost-startStop-1] INFO AtmosphereFramework   - org.atmosphere.interceptor.CorsInterceptor : CORS Interceptor Support 
2015-03-10 16:13:14,517 [ost-startStop-1] INFO AtmosphereFramework   - org.atmosphere.interceptor.CacheHeadersInterceptor : Default Response's Headers Interceptor 

2015-03-10 16:13:14,520 [ost-startStop-1] INFO AtmosphereFramework   - org.atmosphere.interceptor.PaddingAtmosphereInterceptor : Browser Padding Interceptor Support 
2015-03-10 16:13:14,520 [ost-startStop-1] INFO AtmosphereFramework   - org.atmosphere.interceptor.AndroidAtmosphereInterceptor : Android Interceptor Support 

2015-03-10 16:13:14,521 [ost-startStop-1] INFO AtmosphereFramework   - org.atmosphere.interceptor.HeartbeatInterceptor : Heartbeat Interceptor Support 

2015-03-10 16:13:14,521 [ost-startStop-1] INFO AtmosphereFramework   - org.atmosphere.interceptor.SSEAtmosphereInterceptor : SSE Interceptor Support 

2015-03-10 16:13:14,521 [ost-startStop-1] INFO AtmosphereFramework   - org.atmosphere.interceptor.JSONPAtmosphereInterceptor : JSONP Interceptor Support 

2015-03-10 16:13:14,524 [ost-startStop-1] INFO AtmosphereFramework   - org.atmosphere.interceptor.JavaScriptProtocol : Atmosphere JavaScript Protocol 

2015-03-10 16:13:14,524 [ost-startStop-1] INFO AtmosphereFramework   - org.atmosphere.interceptor.WebSocketMessageSuspendInterceptor : org.atmosphere.interceptor.WebSocketMessageSuspendInterceptor 

2015-03-10 16:13:14,525 [ost-startStop-1] INFO AtmosphereFramework   - org.atmosphere.interceptor.OnDisconnectInterceptor : Browser disconnection detection 

2015-03-10 16:13:14,525 [ost-startStop-1] INFO AtmosphereFramework   - org.atmosphere.interceptor.IdleResourceInterceptor : org.atmosphere.interceptor.IdleResourceInterceptor 

2015-03-10 16:13:14,525 [ost-startStop-1] INFO AtmosphereFramework   - Set org.atmosphere.cpr.AtmosphereInterceptor.disableDefaults to disable them. 

2015-03-10 16:13:14,532 [ost-startStop-1] INFO AtmosphereFramework   - Using EndpointMapper class org.atmosphere.util.DefaultEndpointMapper 

2015-03-10 16:13:14,532 [ost-startStop-1] WARN AtmosphereFramework   - No BroadcasterCache configured. Broadcasted message between client reconnection will be LOST. It is recommended to configure the org.atmosphere.cache.UUIDBroadcasterCache 

2015-03-10 16:13:14,532 [ost-startStop-1] INFO AtmosphereFramework   - Default Broadcaster Class: org.atmosphere.cpr.DefaultBroadcaster 

2015-03-10 16:13:14,532 [ost-startStop-1] INFO AtmosphereFramework   - Broadcaster Polling Wait Time 100 

2015-03-10 16:13:14,532 [ost-startStop-1] INFO AtmosphereFramework   - Shared ExecutorService supported: true 

2015-03-10 16:13:14,532 [ost-startStop-1] INFO AtmosphereFramework   - Messaging Thread Pool Size: Unlimited 

2015-03-10 16:13:14,532 [ost-startStop-1] INFO AtmosphereFramework   - Async I/O Thread Pool Size: 200 

2015-03-10 16:13:14,533 [ost-startStop-1] INFO AtmosphereFramework   - Using BroadcasterFactory: org.atmosphere.cpr.DefaultBroadcasterFactory 

2015-03-10 16:13:14,533 [ost-startStop-1] INFO AtmosphereFramework   - Using WebSocketProcessor: org.atmosphere.websocket.DefaultWebSocketProcessor 

2015-03-10 16:13:14,533 [ost-startStop-1] INFO AtmosphereFramework   - Invoke AtmosphereInterceptor on WebSocket message true 

2015-03-10 16:13:14,533 [ost-startStop-1] INFO AtmosphereFramework   - HttpSession supported: false 

2015-03-10 16:13:14,533 [ost-startStop-1] INFO AtmosphereFramework   - Atmosphere is using DefaultAtmosphereObjectFactory for dependency injection and object creation 

2015-03-10 16:13:14,533 [ost-startStop-1] INFO AtmosphereFramework   - Atmosphere is using async support: org.atmosphere.container.Tomcat7Servlet30SupportWithWebSocket running under container: Undefined using javax.servlet/3.0 

2015-03-10 16:13:14,535 [ost-startStop-1] INFO AtmosphereFramework   - Atmosphere Framework 2.2.0 started. 


2015-03-10 16:13:14,576 [ost-startStop-1] INFO SpringCamelContext    - Route: route4 started and consuming from: Endpoint[atmosphere-websocket://localhost:8181/test1] 

Répondre