REST API: atmosphere.js error

Hey there,

i´ m very new to the REST-thing and getting in trouble by just trying to get a connection.

I tried out the following three functions:

	<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js">
</script>

      <script type="text/javascript">
         function WebSocketTest()
         {
            if ("WebSocket" in window)
            {
               alert("WebSocket is supported by your Browser!");
               
               // Let us open a web socket
               var ws = new WebSocket("ws://192.168.178.52:8080/rest/items/FEG_HZ_Ist/state");
				
               ws.onopen = function()
               {
                  // Web Socket is connected, send data using send()
                  ws.send("Message to send");
                  alert("Message is sent...");
               };
				
               ws.onmessage = function (evt) 
               { 
                  var received_msg = evt.data;
                  alert("Message is received...");
               };
				
               ws.onclose = function()
               { 
                  // websocket is closed.
                  alert("Connection is closed..."); 
               };
            }
            
            else
            {
               // The browser doesn't support WebSocket
               alert("WebSocket NOT supported by your Browser!");
            }
         }
         
         
         function getState()
         {
             var request = $.ajax
             ({
                 type       : "GET",
                 url        : "http://192.168.178.52:8080/rest/items/FEG_HZ_Ist/state"
             });

             request.done( function(data) 
             { 
                 console.log( "Success: Status=" + data );
             });

             request.fail( function(jqXHR, textStatus ) 
             { 
                 console.log( "Failure: " + textStatus );
             });
         }
         
         
         
         function test()
         {
         
         var socket = $.atmosphere;

         var request = new $.atmosphere.AtmosphereRequest();

         request.url = "http://192.168.178.52:8080/rest/items?type=json";
         request.contentType = "application/json";
         request.headers = {"Accept": "application/json", "type": "json"};
         request.transport = 'websocket';
         request.fallbackTransport = 'long-polling';

         request.onOpen = function () {
            console.info("opOpen");
          };

          request.onMessage = function (message) {
            console.info("onMessage", message);
             console.info(message.responseBody);
          };

          var subSocket = socket.subscribe(request);
         }

But in every try i get an other error:

FUnction 1: [HTTP/1.1 503 Jersey is not ready yet! 35ms]
Function 2: Firefox kann keine Verbindung zu dem Server unter ws://192.168.178.52:8080/rest/items/FEG_HZ_Ist/state aufbauen. / Firefox could not establish a connection to the server ws://192.168.178.52:8080/rest/items/FEG_HZ_Ist/state aufbauen

Function 3: TypeError: $.atmosphere is undefined

Could anyone help me, how i could get a correct working websocket connection?

Greetings
Dominic

i added the following lines to my runtime.cfg:

com.eclipsesource.jaxrs.connector:cors=enable
org.eclipse.smarthome.cors:enable=true

Now the function 2 works.

FUnction 1 gives me now “Firefox kann keine Verbindung zu dem Server unter ws://192.168.178.52:8080/rest/items/FEG_HZ_Ist/state aufbauen. / Firefox could not establish a connection to the server ws://192.168.178.52:8080/rest/items/FEG_HZ_Ist/state aufbauen”

And function 3 has stile the type error. Do i have to embedd the atmosphere library somehow?

If I interpreted the forum discussions right, I now know that there is no atmosphere.js support in OH2. So instead SSE should be used. I will close this topic and open a new one for my sse problem.