WebSocket on IE10 giving a SecurityError

JavascriptWebsocketInternet Explorer-10

Javascript Problem Overview


I am currently developing a website under IE10 (on Windows 8), using WebSockets in JavaScript. It runs fine under Firefox 18 and Chrome 25, but on IE10 I get a SecurityError when I establish the connection.

What I am doing seems pretty straghtforward :

websocket = new WebSocket('wss://hello.dev.mydomain.net');

But IE doesn't like it :

SCRIPT5022: SecurityError 

The script is on "https://test.dev.mydomain.net" (not the real address obviously).

What bothers me is that if I just double-click the file on my local computer (e.g. file://...) it just works. Even worse: if I use fiddler to monitor HTTP traffic... it also works. Whereas there seems to be no connection at all without fiddler, as detailed in the API's specs. (See below.)

Judging by websocket spec, the exception should also appear on Chrome/Firefox... but it does not. So I doubt it has anything related to HTTP/HTTPS. In any case, I am using a wsS socket on a httpS page... Moreover: when I replace the wss address by another valid server found on an online example, it works.

I don't know if this is relevant, but the IP from test.dev.mydomain.net is 10.14.x.x where hello.dev.mydomain.net is 194.247.x.x. I don't know if it could trigger some kind of security on IE only...

One more thing: I have a certificate for *.dev.mydomain.net, IE does not seems to have problems with it. The script originally resides on a server called my.name.dev.mydomain.net, but since I am accessing it from another URL (I got a redirect since we first thought it could have been some kind of Same Origin Policy issue), I don't see how it could matter. At least I hope it does not...

Any idea is welcomed.

EDIT: adding the sites to the trusted zone does not work either.

Javascript Solutions


Solution 1 - Javascript

It looks like IE throws a SecurityError if you're trying to open a websocket on a local (intranet) domain. To overcome this, you may disable IE's automatic algorithm for recognizing local sites. This can be done in Tools > Internet Options > Security > Local Intranet > Sites.

intranet detection settings

Uncheck all checkboxes (or only a particular one, if you know how exactly your domain did end up in intranet ones).

Note that IE uses (among other things) its proxy settings to determine local sites: if your domain is listed as excluded from proxying in proxy settings, then it will probably be treated as intranet one. This is why WebSockets work if you enable Fiddler: it modifies IE proxy settings and thus the list of intranet sites changes.

Solution 2 - Javascript

I had this problem in Windows7/IE11 after applying a security patch. For Windows10/Edge is the same story.

As this is a local websocket (ws://localhost) you have to add ws:\\localhost\ to Internet Explorer configurations (Tools > Internet Options > Security > Local Intranet > Sites > Advanced).

IE11 local intranet sites configuration

In Windows 10/Microsoft Edge you will find this configuration in Control Panel > Internet Options.

UPDATE

The address of your webapp (https://test.dev.mydomain.net) must be added to the local intranet zone too. Note that in the image the webapp address should be added.

Solution 3 - Javascript

Well, my question wasn't that successful, so I'll post the "workaround" I found.

I got another address for the website, in 194.247.. too. This, magically, solved it. Guess IE doesn't like mixing local and external stuff and watches the IP.

Anyways, I hope this may come in handy to anyone who's got the same issue.

If you have a solution to solve the "real" issue by configuring IE, let me know :)

Cheers,

Solution 4 - Javascript

Browsers has a websocket limitation. For example Internet Explorer has default limit of websocket connections set to 6 per host header name. the same limitation is set for WinForms WebBrowser component.

The solution is to add values under key Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_WEBSOCKET_MAXCONNECTIONSPERSERVER in registry. Just add DWORD value with executable name , for example iexplore.exe (or your application executable name if you use Web browser component) and set value from range 2..128

Second option how to solve SecurityException is to create multiple subdomains.

Solution 5 - Javascript

The client hostname/IP Address should be same as server IP/Hostname thats listening to otherwise you would get the above error.

  1. Make sure whether server hostname configured to listen at IP/localhost etc andif not explicitly specify the hostname ast server

  2. use the same hostname in the client. THis will solve the issue. It worked for me...

Solution 6 - Javascript

I encountered the error (although it did not say the SCRIPT5022 part, rather it just reports "ScriptError"). I got around the issue by clicking on "Trusted Sites" and then adding the machine hosting the remote websocket. Note, to add to trusted sites,

  • I had to supply the address without the "ws://" part (like just mymahcine.mydomain.com)

  • I had to uncheck the box that says "Require server verification https:// " option.

  • After I was done adding the domain, I re-checked the box "Require server verification (https://). I would recommend everyone to do the same. Unchecking the box is only a workaround to add sites that don't begin with https (rather ws:// in my case)

Solution 7 - Javascript

I had the same issue at one of my customer's environment. It turned out that they had a proxy configuration that did not allow the connection to the WebSocket endpoint directly and did not support the WebSocket protocol. The temporary solution was to disable using the proxy and everything started working. The long term solution is to edit the proxy's configuration (.pac file) to exclude the address of the WebSocket endpoint.

To disable the proxy, go to: Internet Explorer Options > Connections tab > LAN settings button > un-check Automatically detect settings.

Hope this helps someone.

Solution 8 - Javascript

In addition to making sure that the internet zone is not localhost (as in above answers), ensure that if https is used, then wss should be used.

This is not an issue in other browsers, but IE is abit more finicky.

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionEldredBView Question on Stackoverflow
Solution 1 - JavascriptGeorgii IvankinView Answer on Stackoverflow
Solution 2 - JavascriptlmiguelmhView Answer on Stackoverflow
Solution 3 - JavascriptEldredBView Answer on Stackoverflow
Solution 4 - JavascriptRudolf DvoracekView Answer on Stackoverflow
Solution 5 - JavascriptLokeshView Answer on Stackoverflow
Solution 6 - JavascriptNurAlDinView Answer on Stackoverflow
Solution 7 - JavascriptDoronGView Answer on Stackoverflow
Solution 8 - JavascriptblackeningView Answer on Stackoverflow