I am using the Atmosphere 2.0.0.RC5 environment to extend my web application using websocket functions and I encountered some strange error "Websocket failed. Transition to comet and redirect", which I cannot leave.
I used the websocket chat example as a starting point: https://github.com/Atmosphere/atmosphere-samples/tree/master/samples/websocket-chat
The application has an html + js client and a java server.
Backend
- Tomcat 7.0.42 with NIO enabled
- Web Module v3.0 with Spring and Atmosphere Servlets
- Custom CORS filter for creating atmosphere headers.
- Each received message is logged by the server.
(optional code omitted)
public void onTextMessage(WebSocket webSocket, String message) throws IOException { logger.info("Message received: " + message); webSocket.broadcast(mapper.writeValueAsString(mapper.readValue(message, Data.class))); }
Client
index.html
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript" src="js/lib/jquery.atmosphere-2.0.2.js"></script> <script type="text/javascript" src="js/aimpl.js"></script>
aimpl.js
$(function() { "use strict"; var socket = $.atmosphere; var request = { url: 'http://localhost:8181/services/echo', transport: "websocket", contentType: "application/json", //connectTimeout: '300000', fallbackTransport: 'long-polling', enableXDR: true, logLevel: 'debug' }; request.onMessage = function (response) { console.log(response.responseBody) }; request.onOpen = function(response) { console.log('Atmosphere connected using ' + response.transport); }; request.onReconnect = function (request, response) { console.log("reconnecting..."); }; request.onError = function(response) { console.log('an error has occured.'); }; var channel = socket.subscribe(request); channel.push(JSON.stringify({ author: 'me', message: 'hello from websocket!' })); });
When I open "index.html", I see an error in the console (jquery.atmosphere-2.0.2.js 1097 line) and messages in the server log:

Surprisingly, this works when I type directly in the console:

And it registers with the server, so I assume the part of the server is beautiful:

I assume this is a javascript issue, but I'm not 100% sure. I played with the connectTimeout parameter with no luck. Any ideas why this is not working in the script?