WebSocket for localhost does not work on Microsoft Edge

I created a simple WebSocket server and am trying to connect to it with the following code:

function test(name) { var ws = new WebSocket('ws://localhost:1234'); ws.onopen = function () { ws.send('Hello from ' + name); } } test('Edge'); 

This works fine with Chrome and IE11 on Windows10, but when I try to use Edge, the onopen function onopen not called, instead I get the following error:

SCRIPT12029: WebSocket Error: Network Error 12029, Unable to Connect to Server

This happens for Edge version 12.10240.

A similar problem arose over here , but the error message is different.

Things I tried:

  • IP - localhost , 127.0.0.1 , actual IP
  • Allow Local Host Flags - Turn On / Off

When you try to contact another computer, the problem does not occur.

Is this a defect in Edge or am I doing something wrong?

+9
source share
1 answer

I had a similar problem, but that was when going to pages in a browser. I could use the phrase localhost and it worked fine, but I did not work when I used the machine name. I found this forum where they suggested running the following command on the admin command line:

 CheckNetIsolation LoopbackExempt -a -n=Microsoft.MicrosoftEdge_8wekyb3d8bbwe 

Worked for me. I thought you might see some form of the same problem.

As the forum suggests, now you can also do this by opening Edge and going to the “ about: flags ” item, then ticking “ Allow localhost feedback (this could put your device at risk )” in the “Developer Settings” section. It should be a little safer than inserting random things into the command line.

Edit: As indicated below in tresf, the loopback flag in about: flags seems to have stopped working (as a fix), so you have to use the CheckNetIsolation command to exclude Edge.

+10
source

All Articles