Web socket does not work in Firefox 12

Firefox cannot establish a connection to the server at ws: //192.168.0.155: 5555 / socket / server3.php.

$(document).ready(function(){
if(!("WebSocket" in window)){
alert('not available');
}else{
_init(); 
}
});
function _init(){
     var websocket;
     var host = 'ws://192.168.0.155:5555/socket/server3.php';
     try{
     websocket = new WebSocket(host);
     websocket.onopen = function(evt){ onOpen(evt); };
     websocket.onclose = function(evt) { onClose(evt); };
     websocket.onmessage = function(evt) { onMessage(evt); };
     }catch(exception){
     alert(exception);
     }
     }

  function onOpen(evt){
    $('.logger_screen').append('Connected');
      }

  function onClose(evt){
      $('.logger_screen').append('Disconnected');
       }

  function onMessage(evt){
    $('.logger_screen').append(evt.data);
   }

wts wrong with my code?

+3
source share
1 answer

From one of your comments, I think you are using phpwebsocket on the server. This project does not seem to be supported or updated with changes to the websocket protocol specification.

There are two incompatible versions of the websocket protocol used. Safari still uses the original (now obsolete) version of Hixie , which implements phpwebsocket; Firefox, IE10 and Chrome use the new version of Hybi .

, Safari javascript.

, , PHP , Safari. , . , , , websocket, .

+2

All Articles