WebSocket to localhost not working on Microsoft Edge

前端 未结 1 1883
悲哀的现实
悲哀的现实 2020-12-30 07:31

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

function test(name) {
    var ws = new WebSocket(\'ws://local         


        
相关标签:
1条回答
  • 2020-12-30 08:15

    I had a similar problem, but it was when actually navigating to pages in the browser. I could use the phrase localhost and it worked fine, but I didn't work when I used my machine's name. I found this forum where they suggested that you run the following command in a administrator prompt:

    CheckNetIsolation LoopbackExempt -a -n=Microsoft.MicrosoftEdge_8wekyb3d8bbwe
    

    Worked for me. Thought you might be seeing some form of the same issue.

    As the forum suggests, you can now also do this by opening Edge and navigating to "about:flags", then tick "Allow localhost loopback (this might put your device at risk)" under "Developer Settings". Should feel a little safer than pasting random stuff into your command prompt.

    Edit: As tresf pointed out below, the loopback checkbox in the about:flags appears to have stopped working (as a fix), so you'll have use the CheckNetIsolation command, to make Edge exempt.

    0 讨论(0)
提交回复
热议问题