Cross-domain SignalR does not work in IE<=9 - asp.net

I am using SignalR-1.0.0-rc2.
I am using cross domain SignalR because some browsers on mobile devices still only allow two connections per domain. So I have one domain for SignalR and one for the web. Server-side, they are both the same.
My implementation works for Opera, Firefox, Chrome, Safari, and IE10. It does not work for IE9, IE8 and IE7.
jQuery.support.cors = true;
var connection = $.connection.globalHub;
$.connection.hub.url = SignalRDomain;
$.connection.hub.logging = true;
$.connection.hub.qs = "UserID="+UserID+"&Login="+UserLogin+"&UserHash="+UserHash;
connection.client.MyLocalFunction = function () {
// do something
}
$.connection.hub.start();
I have logging turned on. The IE9/8/7 consoles show me two SignalR trace messages:
[13:54:37 UTC+0100] SignalR: Auto detected cross domain url.
[13:54:37 UTC+0100] SignalR: Negotiating with 'http://live.mydomain.de/signalr/negotiate'.
If I look in the "Network"-tab of the debugger I don't see that any call to the server is made. So it seems that SignalR just dies after that debug message.
Any ideas?

So here's the reason why the request is failing: IE9 jQuery AJAX with CORS returns "Access is denied"
You can fix this issue by removing the line "jQuery.support.cors = true".
For SignalR 1.0.0-rc2 it will just work, however for all versions of SignalR 1.0.0 and above you will need to enable cross domain in your map hubs call: SignalR cross domain not working on browsers other than IE10

Related

How do you initialize the Twilio Client in Meteor JS?

I'm having incredible difficulty setting up the Twilio Client in Meteor JS, and would really appreciate any help.
I have extracted the relevant code and error logs below. So far as I can tell, it should be simple. The code is just grabbing an authtoken which I have previously generated, and then trying to set up the device using that authtoken. But it's not working.
'click #initializeDevice'(event) {
var thisAuthToken = Session.get('myAuthToken');
console.log(thisAuthToken); // I have confirmed with Twilio support that these authtokens are correctly generated
const Device = require('twilio-client').Device;
Device.setup(thisAuthToken, { debug: true });
var myStatus = Device.status()
console.log(myStatus); //this is logging "offline"
Device.on('ready',function (device) {
log('Twilio.Device Ready!'); //this is not logging anything
});
},
When that code runs, it generates the following logs:
eyJhbGciDpvdXRnb2luZz9hcHBTaWQ9QVA2NDE2MzJmMzA1ZjJiY2I[Note:I have deleted part of the middle of the logged authtoken for the purpose of this public post]5YmMxOGQyOWVlNGU2ZGM0NjdmMzRiNDVhNCIsImV4cCI6MTU3Nz0ygbJKTx15GgNCWDkm-iUPjn_O1NZU6yovp4vjE
modules.js?hash=69069bec9aeba9503ae3467590cf182be57d9e62:3605 Setting up VSP
modules.js?hash=69069bec9aeba9503ae3467590cf182be57d9e62:3605 WSTransport.open() called...
modules.js?hash=69069bec9aeba9503ae3467590cf182be57d9e62:3605 Attempting to connect...
modules.js?hash=69069bec9aeba9503ae3467590cf182be57d9e62:3605 Closing and cleaning up WebSocket...
modules.js?hash=69069bec9aeba9503ae3467590cf182be57d9e62:3605 No WebSocket to clean up.
modules.js?hash=69069bec9aeba9503ae3467590cf182be57d9e62:3605 Could not connect to endpoint: ws does not work in the browser. Browser clients must use the native WebSocket object
modules.js?hash=69069bec9aeba9503ae3467590cf182be57d9e62:3605 Closing and cleaning up WebSocket...
modules.js?hash=69069bec9aeba9503ae3467590cf182be57d9e62:3605 No WebSocket to clean up.
calltemplate.js:31 offline
I'm doing this all from a local server, tunneled through NGROK. I've also set up the Twilio back end, linked the app, purchased a number, etc.
So far as I can tell, the issue, from the logs, appears to be something to do with the way that Meteor uses WebSockets.
Could not connect to endpoint: ws does not work in the browser. Browser clients must use the native WebSocket object
This is a not a Meteor related problem rather than browser issue.
Make sure your browser supports WebRTC
BTW, Your browser might be supporting it but you'd need to enable it.

Failed to load resource: net::ERR_INSECURE_RESPONSE

IS there a way to trick the server so I don't get this error:
Content was blocked because it was not signed by a valid security certificate.
I'm pulling an iframe of an html website into another website but I keep getting the console (chrome) error in the title of this question and in internet explorer it says:
Content was blocked because it was not signed by a valid security certificate.
Your resource probably use a self-signed SSL certificate over HTTPS protocol.
Chromium, so Google Chrome block by default this kind of resource considered unsecure.
You can bypass this this way :
Assuming your frame's URL is https://www.domain.com, open a new tab in chrome and go to https://www.domain.com.
Chrome will ask you to accept the SSL certificate. Accept it.
Then, if you reload your page with your frame, you could see that now it works
The problem as you can guess, is that each visitor of your website has to do this task to access your frame.
You can notice that chrome will block your URL for each navigation session, while chrome can memorise for ever that you trust this domain.
If your frame can be accessed by HTTP rather than HTTPS, I suggest you to use it, so this problem will be solved.
Sometimes Google Chrome throws this error, even if it should not.
I experienced it when Chrome had a new version, and it needed to be restarted.
After restarting the same page worked without any errors.
The error in the console was:
net::ERR_INSECURE_RESPONSE
I still experienced the problem described above on an Asus T100 Windows 10 test device for both (up to date) Edge and Chrome browser.
Solution was in the date/time settings of the device; somehow the date was not set correctly (date in the past). Restoring this by setting the correct date (and restarting the browsers) solved the issue for me. I hope I save someone a headache debugging this problem.
Offering another potential solution to this error.
If you have a frontend application that makes API calls to the backend, make sure you reference the domain name that the certificate has been issued to.
e.g.
https://example.com/api/etc
and not
https://123.4.5.6/api/etc
In my case, I was making API calls to a secure server with a certificate, but using the IP instead of the domain name. This threw a Failed to load resource: net::ERR_INSECURE_RESPONSE.
open up your console and hit the URL inside. it'll take you to the API page and then in the page accept the SSL certificate, go back to your app page and reload.
remember that SSL certificates should have been issued for your Dev environment before.
If you're developing, and you're developing with a Windows machine, simply add localhost as a Trusted Site.
And yes, per DarrylGriffiths' comment, although it may look like you're adding an Internet Explorer setting...
I believe those are Windows rather than IE settings. Although MS tend to assume that they're only IE (hence the alert next to "Enable Protected Mode" that it requries restarted IE)...
Try this code to watch for, and report, a possible net::ERR_INSECURE_RESPONSE
I was having this issue as well, using a self-signed certificate, which I have chosen not to save into the Chrome Settings. After accessing the https domain and accepting the certificate, the ajax call works fine. But once that acceptance has timed-out or before it has first been accepted, the jQuery.ajax() call fails silently: the timeout parameter does not seem help and the error() function never gets called.
As such, my code never receives a success() or error() call and therefore hangs. I believe this is a bug in jquery's handling of this error. My solution is to force the error() call after a specified timeout.
This code does assume a jquery ajax call of the form jQuery.ajax({url: required, success: optional, error: optional, others_ajax_params: optional}).
Note: You will likely want to change the function within the setTimeout to integrate best with your UI: rather than calling alert().
const MS_FOR_HTTPS_FAILURE = 5000;
$.orig_ajax = $.ajax;
$.ajax = function(params)
{
var complete = false;
var success = params.success;
var error = params.error;
params.success = function() {
if(!complete) {
complete = true;
if(success) success.apply(this,arguments);
}
}
params.error = function() {
if(!complete) {
complete = true;
if(error) error.apply(this,arguments);
}
}
setTimeout(function() {
if(!complete) {
complete = true;
alert("Please ensure your self-signed HTTPS certificate has been accepted. "
+ params.url);
if(params.error)
params.error( {},
"Connection failure",
"Timed out while waiting to connect to remote resource. " +
"Possibly could not authenticate HTTPS certificate." );
}
}, MS_FOR_HTTPS_FAILURE);
$.orig_ajax(params);
}
This problem is because of your https that means SSL certification. Try on Localhost.

Stopping SignalR-connection is slow

Stoping SignalR connection of Javascript client is slow (around 30 seconds).
I use SignalR, version 2.0.1 (but problem reproduced in 2.0.0 ) for webchat integrated to ASP.NET site. I have one .NET SignalR client(for other reason) and a lot of JS clients (chat clients). My test case is very simple. I want to disable chat on ASP.NET page. For this reason I try to stop SignalR connection using next code:
$.connection.hub.stop();
But onDisconnected method (on hub) was calling only after 30 seconds. I suppose that connection was stopped by disconnect timeout but not by Javascript code. I use LongPolling transpot by default.
var initObject = { transport: ["longPolling", "webSockets", "foreverFrame", "serverSentEvents"] };
$.connection.hub.start(initObject).done(function () {
...
}
Problem reproduce in last versions of Google Chrome but works fine in IE and Mozilla. What reason of so strange behaviour of SignalR and how can I avoid it?
For anyone else having this issue just use conn.Stop(new TimeSpan(0)) to kill the connection instantly.
conn.disconnect();
conn.stop();
hub.subscribe(null);
conn = null;
hub= null;
try this and let me know if it works.It works in android though.
The problem is solved by updating SignalR version to the 2.0.3.

Security alert when using "longpoling" connection with SignalR, while in secure connection (HTTPS) | IE8

There is only one problem, I am just getting a "Securty Waring" alert in IE 8 in my SignalR chat application while in HTTPS
I am using longpolling as transport type when in IE8. Its working fine in all other IE browers.
self.Connect = function () {
hubConn.start({ transport: 'longPolling' }).done(function (result) {
///--
}).fail(function (error) {
///--
alert("error" + error);
});
}
When I tried fiddler, the security warning appeared with a signalr ajax call as shown below.
Various possibilities of security warning in IE is explained in the below url
ie7-this-page-contains-both-secure-and-nonsecure-items
The problem was actually not with the signalr chat and i have detailed the cause of my issue in the url given below.
Security+warning+in+IE+version+8
Thanks guys for your support :)
Best,
Linto Sebastian

SignalR IE9 Cross Domain request don't work

I'm making an application using SignalR.
The Hub is placed on one server running Windows Server 2012 with IIS 8.
http://mentor.cloudapp.net/mass/rexona/previa/signalr/hubs.
The client is here:
http://massdeveloperstage.com/Rexona/Site/colombia/Previa/Match?matchId=6F318A29-3400-444B-95D9-7EC41A7AD2D4
The Signalr set up looks like this:
var match;
$(document).ready(function () {
$.connection.hub.loging = true;
match = $.connection.match;
match.client.addMessage = function (message) {
var vm = {
avatar: message.ProfileImageLocation,
content: message.Text,
user: message.UserScreenName,
obj: JSON.stringify(message)
};
alert(vm.obj);
}
$.connection.hub.url = 'http://mentor.cloudapp.net/mass/rexona/previa/signalr';
$.connection.hub.start().done(function () {
match.server.addToGroup("97-987-PP");
}).fail(function () {
//alert("fail!");
});
Everything works perfectly in Chrome, FF, Opera and in IE10, but when it's accessed using IE9 the application fails.
Am I missing something in the set up of the connection? Do I need to enable something else on the server in order to work with IE9?
Thanks.
I think you're trying to do CORS (Cross-Site Origin Sharing) there. It doesn't work quite like that with IE9, check this for detailed discussion, and microsoft page for the exact limitations. It is done with XDomainRequest custom object instead of XMLHttpRequest, and...
The target URL must be accessed using the HTTP or HTTPS protocols
The target URL must be accessed using only the HTTP methods GET and POST
No custom headers may be added to the request
Only text/plain is supported for the request's Content-Type header (no soap, json or encoded data types!)
No authentication or cookies will be sent with the request
Requests targeted to Intranet URLs may only be made from the Intranet Zone
Requests must be targeted to the same scheme as the hosting page
Edit: I haven't actually ever used SignalR myself, this answer was based on CORS in general. According to a comment by #stricq, IE needs long polling enabled for this to work with SignalR, as explained in here.

Resources