Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Websocket undefined in Edge Browser

I developed a multiplayer card game and therefore used a websocket. To implement the websocket in php, I used this library

I'v put it to my ubuntu server and the program works fine on Chrome Browser and in Firefox (The frontend is implemented using Javascript). Using the Edge Browser, there is an error stating "ReferenceError: WebSocket is undefined". But on the internet I have read that Edge should normally support websockets.

I already checked, whether the document mode is another IE version, but it is set to edge as well. The exact version is 11.0.0600.18537.

The following is my code (althoug I don't think that is is a problem with it as it works in the other browsers)

 connectToSocket=function() {
    var host = "ws://[host]:9000/echobot"; 

    try
    {
       socket = new WebSocket(host);
       console.log('WebSocket - status ' + socket.readyState);
       ...
    }
    catch(ex){
        console.log('some exception : ' +ex);      
    }

Does anybody know what could be the issue with Edge?

like image 672
user2550641 Avatar asked Jan 31 '17 12:01

user2550641


1 Answers

Are you sure you are actually writing WebSocket in your code? The error says that Websocket is not defined (with non-capitalized s).

The actual classname is WebSocket with a capital S.

Please confirm that the code you pasted as an example is really the same as the one you have in your application.

EDIT

After some further discussion in the comments I believe that WebSocket support might be disabled in your browser. WebSocket should be supported in your browser version (11.0.0600.18537) according to my own experiment and Can I Use.

like image 129
Ricardo Velhote Avatar answered Oct 07 '22 18:10

Ricardo Velhote