PHP Websocket undefined in Edge Browser
Asked Answered
A

1

14

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?

Agathy answered 31/1, 2017 at 12:7 Comment(1)
your edge is miles out of date, just check that click the 3 dots click settings and scroll to the bottom mine on the latest version is running Microsoft Edge 38.14393.0.0 however this is going to change soon as a new Release of windows 10 is dueBuzzer
L
8

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.

Laverty answered 6/2, 2017 at 9:53 Comment(10)
But OP says it works fine except Edge, sure it would be nice to know from OPColum
Sorry, I edited the error in my question. Indeed, the error says "WebSocket" and the code is correct :-)Agathy
@Agathy Are running the code on localhost or 127.0.0.1 or connecting to localhost or 127.0.0.1? Try connecting to ws://echo.websocket.org in case it's a weird IE error and also perhaps testing in the browser the following address http://www.websocket.org/echo.htmlLaverty
Calling the url you mentioned (websocket.org/echo.html), the following error occurs: "Uh-oh, the browser you're using doesn't have native support for WebSocket. That means you can't run this demo." This obviously means, that my browser has no support for Websockets. But all over the web it is said, that this version of IE should support this...Agathy
@Agathy Are you sure you're using a supported browser? I just tried in an IE11 VM with the exact version you specified (11.0.0600.18537) and it works: imgur.com/otHTKkOLaverty
there is also a field with "updateversions" which is: 11.0.38. Its a corporate browser, maybe there has been something disabled?Agathy
@Agathy Possibly: msdn.microsoft.com/en-us/library/…Laverty
Do you know, how to manage the feature controls? I looked in the installation folder of IE and in the internet options in the browser but there is no file that can be adapted or looks simliar to thisAgathy
@Agathy Sadly I don't have that knowledge. You should discuss that issue with your systems administrator.Laverty
Ok, seems to be the only possibility...I assume, that it has been disabled due to security reasons of the company...thank you for your support, at least, I can be sure now, that there is nothing to do on my side :-) Therefore I will accept your answer now.Agathy

© 2022 - 2024 — McMap. All rights reserved.