WebSocket on IE10 giving a SecurityError

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.

Answers


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.

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.


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,


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 Explore configurations (Tools > Internet Options > Security > Local Intranet > Sites > Advanced).

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.


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...


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.


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)

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.


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.


Need Your Help

Export default was not found

javascript import module ecmascript-6 vue.js

I have a Vue 2 project, and I've written a simple function for translating months in dates, which I would like to import in one of my components, but I'm getting an error: