Scott Hanselman

Asynchronous scalable web applications with real-time persistent long-running connections with SignalR

August 29, '11 Comments [92] Posted in ASP.NET | IIS | Javascript | SignalR
Sponsored By

I've been spending some time exploring asynchrony and scale recently. You may have seen my post about my explorations with node.js and iisnode running node on Windows.

Every application has different requirements such that rules to "make it scale" don't work for every kind of application. Scaling a web app that gets some data and for loops over it is different from an app that calls out to a high-latency mainframe is different from an app that needs to maintain a persistent connection to the server.

The old adage "when all you have it is a hammer everything looks like a nail" really holds true in the programming and web space. The more tools - and the knowledge to use them - the better. That's why I'm an advocate not only of polyglot programming but also of going deep with your main languages. When you really learn LINQ for example and get really good at dynamics, C# becomes a much more fun and expressive language.

Polling is a common example of hammering a screw. Trying to make a chat program? Poll every 5 seconds. Got a really long running transaction? Throw up an animated GIF and poll until eternity, my friend!

Long polling is another way to get things done. Basically open a connection and keep it open, forcing the client (browser) to wait, pretending it's taking a long time to return. If you have enough control on your server-side programming model, this can allow you to return data as you like over this "open connection." If the connection breaks, it's transparently re-opened and the break is hidden from both sides. In the future things like WebSockets will be another way to solve this problem when it's baked.

Persistent Connections in ASP.NET

Doing this kind of persistent connection in a chat application or stock ticker for example hasn't been easy in ASP.NET. There hasn't been a decent abstraction for this on the server or a client library to talk to it.

SignalR is an asynchronous signaling library for ASP.NET that our team is working on to help build real-time multi-user web application.

Isn't this just Socket.IO or nowjs?

Socket.IO is a client side JavaScript library that talks to node.js. Nowjs is a library that lets you call the client from the server. All these and Signalr are similar and related, but different perspectives on the same concepts. Both these JavaScript libraries expect certain things and conventions on the server-side, so it's probably possible to make the server look the way these clients would want it to look if one wanted.

SignalR is a complete client- and server-side solution with JS on client and ASP.NET on the back end to create these kinds of applications. You can get it up on GitHub.

But can I make a chat application in 12 lines of code?

I like to say

"In code, any sufficient level of abstraction is indistinguishable from magic."

That said, I suppose I could just say, sure!

Chat.DoItBaby()

But that would be a lie. Here's a real chat application in SignalR for example:

Client:

var chat = $.connection.chat;
chat.name = prompt("What's your name?", "");

chat.receive = function(name, message){
$("#messages").append("
"+name+": "+message);
}

$("#send-button").click(function(){
chat.distribute($("#text-input").val());
});

Server:

public class Chat : Hub {
public void Distribute(string message) {
Clients.receive(Caller.name, message);
}
}

That's maybe 12, could be 9, depends on how you roll.

More details on SignalR

SignalR is broken up into a few package on NuGet:

  • SignalR - A meta package that brings in SignalR.Server and SignalR.Js (you should install this)
  • SignalR.Server - Server side components needed to build SignalR endpoints
  • SignalR.Js - Javascript client for SignalR
  • SignalR.Client - .NET client for SignalR
  • SignalR.Ninject - Ninject dependeny resolver for SignalR

If you just want to play and make a small up, start up Visual Studio 2010.

First, make an Empty ASP.NET application, and install-package SignalR with NuGet, either with the UI or the Package Console.

Second, create a new default.aspx page and add a button, a textbox, references to jQuery and jQuery.signalR along with this script.









    Low Level Connection

    Notice we're calling /echo from the client? That is hooked up in routing in Global.asax:

    RouteTable.Routes.MapConnection("echo", "echo/{*operation}");

    At this point, we've got two choices of models with SignalR. Let's look at the low level first.

    using SignalR;
    using System.Threading.Tasks;

    public class MyConnection : PersistentConnection
    {
    protected override Task OnReceivedAsync(string clientId, string data)
    {
    // Broadcast data to all clients
    return Connection.Broadcast(data);
    }
    }

    We derive from PersistentConnection and can basically do whatever we want at this level. There's lots of choices:

    public abstract class PersistentConnection : HttpTaskAsyncHandler, IGroupManager
    {
    protected ITransport _transport;

    protected PersistentConnection();
    protected PersistentConnection(Signaler signaler, IMessageStore store, IJsonStringifier jsonStringifier);

    public IConnection Connection { get; }
    public override bool IsReusable { get; }

    public void AddToGroup(string clientId, string groupName);
    protected virtual IConnection CreateConnection(string clientId, IEnumerable groups, HttpContextBase context);
    protected virtual void OnConnected(HttpContextBase context, string clientId);
    protected virtual Task OnConnectedAsync(HttpContextBase context, string clientId);
    protected virtual void OnDisconnect(string clientId);
    protected virtual Task OnDisconnectAsync(string clientId);
    protected virtual void OnError(Exception e);
    protected virtual Task OnErrorAsync(Exception e);
    protected virtual void OnReceived(string clientId, string data);
    protected virtual Task OnReceivedAsync(string clientId, string data);
    public override Task ProcessRequestAsync(HttpContext context);
    public void RemoveFromGroup(string clientId, string groupName);
    public void Send(object value);
    public void Send(string clientId, object value);
    public void SendToGroup(string groupName, object value);
    }

    High Level Hub

    Or, we can take it up a level and just do this for our chat client after adding

    <script src="/signalr/hubs" type="text/javascript"></script>

    to our page.

    $(function () {
    // Proxy created on the fly
    var chat = $.connection.chat;

    // Declare a function on the chat hub so the server can invoke it
    chat.addMessage = function (message) {
    $('#messages').append('
  • ' + message + '');
    };

    $("#broadcast").click(function () {
    // Call the chat method on the server
    chat.send($('#msg').val());
    });

    // Start the connection
    $.connection.hub.start();
    });
  • Then there is no need for routing and the connection.chat will map to this on the server, and the server can then call the client back.

    public class Chat : Hub
    {
    public void Send(string message)
    {
    // Call the addMessage method on all clients
    Clients.addMessage(message);
    }
    }

    At this point your brain should have exploded and leaked out of your ears. This is C#, server-side code and we're telling all the clients to call the addMessage() JavaScript function. We're calling the client back from the server by sending the name of the client method to call down from the server via our persistent connection. It's similar to NowJS but not a lot of people are familiar with this technique.

    SignalR will handle all the connection stuff on both client and server, making sure it stays open and alive. It'll use the right connection for your browser and will scale on the server with async and await techniques (like I talked about in the node.js post where I showed scalable async evented I/O on asp.net).

    Want to see this sample running LIVE?

    We've got a tiny tiny chat app running on Azure over at http://jabbr.net/, so go beat on it. There are folks in /join aspnet. Try pasting in YouTube links or images!

    SignalR Chat

    It's early, but it's an interesting new LEGO piece for .NET that didn't completely exist before. Feel free to check it out on GitHub and talk to the authors of SignalR, David Fowler and Damian Edwards. Enjoy.

    About Scott

    Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

    facebook twitter subscribe
    About   Newsletter
    Sponsored By
    Hosting By
    Dedicated Windows Server Hosting by ORCS Web
    Monday, August 29, 2011 9:39:17 AM UTC
    It simple superb!
    Monday, August 29, 2011 9:51:10 AM UTC
    Hi Scott,

    Is this a prototype project? Will this project make it into the core asp.net library?

    Thanks
    Anon
    Monday, August 29, 2011 9:54:23 AM UTC
    Yes and maybe? Depends on how much you like it. ;)

    Why does it need to be core? It works now.
    Scott Hanselman
    Monday, August 29, 2011 10:19:21 AM UTC
    Looks good, but I'm not sure about the assertion that this didn't completely exist before is accurate; for example take a look at Frozen Mountain WebSync which is a commercial product that provides 'comet' style functionality for ASP.NET (works on Azure also). I also thought MS's own Tomek Janczuk and the interoperability team were working on something similar (including a Websocket implementation on top of WCF)

    Still, this looks impressive and I'll definitely try it out. Ideally, the IE team would ship WebSocket support in IE tomorrow, and the WCF and ASP.NET teams would do the same for the server-side. Of course, we have to wait for W3C to hurry up and finalise WebSocket in the first instance!
    Monday, August 29, 2011 10:38:16 AM UTC
    This looks great. I had set aside this morning to do some investigation into the options that are available for long running async with client side js / server side asp.net for an upcoming project - this is looking promising already :)
    Monday, August 29, 2011 11:50:45 AM UTC
    Is the server part able to interoperate with HTML5 Server Side Events implemented by almost any major HTML5 browser (except IE9)?
    Monday, August 29, 2011 12:06:33 PM UTC
    There's also the open source ASPComet which, like WebSync is an in-process Comet server and it uses the cometd javascript library for client side communications.
    Symon Rottem
    Monday, August 29, 2011 12:09:04 PM UTC
    Oh, and I should have posted a link to ASPComet (https://github.com/nmosafi/aspComet) and cometd (http://cometd.org).
    Symon Rottem
    Monday, August 29, 2011 2:48:31 PM UTC
    I need something like this for a mobile application. Are you aware of anyone looking to implement Objective-C or Java client libraries?
    Monday, August 29, 2011 2:53:12 PM UTC
    One of our developers put together something fairly cool for long running web applications using Growl.
    Monday, August 29, 2011 3:23:37 PM UTC
    What is the story on the thread-handling here? Would a website with 1000's of users occupy one thread each on the server or is there something magic offloading the IIS?
    Monday, August 29, 2011 4:03:06 PM UTC
    Does this work with MVC?
    Anton
    Monday, August 29, 2011 5:13:15 PM UTC
    I'm getting "unable to load type" errors loading the PersistentCollection type while trying to map the "echo" to MyConnection. Any ideas, I'm just working out of an empty MVC3 project in VS2010 with SignalR loaded via Nuget?
    Monday, August 29, 2011 5:15:28 PM UTC
    is this inproc? can this be used in azure?
    Monday, August 29, 2011 5:59:28 PM UTC
    Figured it out, since I'd named the project signalR that I was working it, it was looking for the classes there. Woops.
    Monday, August 29, 2011 6:58:52 PM UTC
    Scott,
    Thanks for sharing this.
    You have missed one include line in the "High Level Hub" example:

    <script src="/signalr/hubs" type="text/javascript"></script>
    Monday, August 29, 2011 8:27:46 PM UTC
    Hi Scott, I wonder if you could address the concerns raised by Korriban and Sebastian. I'm working on a project right now utilizing WebSocket, and recently discovered Server-Side Events would serve my needs and may be a better/simpler solution. I'm concerned about hosting connections on IIS and how the communication betweeen client and server is actually handled (WebSocket, SSE, something else?).

    Thanks for the great info either way, and everything else you contribute as well :)

    Matt
    Tuesday, August 30, 2011 3:20:06 AM UTC
    Scott, you got to implement a style for printing.
    Right now if one wants to print out a post it's a nightmare. Text only takes half of the pages width.
    Taran
    Tuesday, August 30, 2011 6:42:48 AM UTC
    Scott, I'm quite happy to see more open source component direct from Microsoft - or is it just a project you're built in spare time?
    Tuesday, August 30, 2011 7:00:37 AM UTC
    Hi Scott,
    one important notice for IE9 users - web page should contain <!DOCTYPE html> to force IE use "Internet Explorer 9" document mode rather than "Quircks mode".
    In "Quircks" mode on the step on initialization SignalR will throw exception "SignalR: No JSON parser found. Please ensure json2.js is referenced before the SignalR.js file if you need to support clients without native JSON parsing support, e.g. IE<8."

    Alexey.
    Alexey
    Tuesday, August 30, 2011 7:36:06 AM UTC
    Have you performed any performance tests on SignalR? Can you share the results of the same?
    Tuesday, August 30, 2011 2:23:37 PM UTC
    Great.
    Does it make to sense to use Signal with .net client?

    I have a client-server app (wcf services+wpf client) where client polls its server for events.
    Will SignalR be better (read: more scalable) that polling server via WCF?
    Tuesday, August 30, 2011 8:26:40 PM UTC
    There are a boatload of commercial offerings in this area.

    http://stackoverflow.com/questions/65673/comet-implementation-for-asp-net
    Jed
    Wednesday, August 31, 2011 3:07:08 AM UTC
    Here you can find the chat sample and some other cool examples: https://github.com/SignalR/SignalR/tree/master/SignalR.Samples/Hubs/Chat
    Wednesday, August 31, 2011 9:24:38 PM UTC
    @Sebastian Nilsson It's async ASP.NET and IIS, threads aren't being tied up by open connections. The defaults for ASP.NET 4.0 are set to 5000 concurrent requests per CPU.

    @Hemanshu Bhojak We don't have numbers for you yet, but when we do, we'll post them.

    @Anton Yes? Not sure what you mean by work with mvc. Are you asking if it can work in an mvc application?

    @Korriban Not yet, and the vast majority of browsers don't support that yet. And even when they do, all people using your app won't have it, so you'll need some kinda of fallback.

    @Symon Rottem Comet is an umbrella term. Signalr is an abstraction over a persistent connection. The connection may use different transports to pass messages. The default is long polling, and you can expect something like websockets when that works well enough.


    David Fowler
    Wednesday, August 31, 2011 10:36:08 PM UTC
    Thanks for the additional information David. It looks pretty good, will definitely be evaluating for projects. Regarding Server-Sent Events, according to caniuse.com every major browser besides IE and Android do indeed support it. It would be a perfect solution for what I need to do right now, and I do know that all my users will have support for it.

    Great work on the project, thanks for the contribution!

    Thursday, September 01, 2011 7:21:35 AM UTC
    Could the server be used in a web farm scenario (i.e. where does it store information about connected clients and if it is in-memory, could this be customized to be out-of-process)?
    John
    Thursday, September 01, 2011 7:33:57 AM UTC
    @John Yes, we're still working on it but there's a SignalR.ScaleOut assembly that has components for setting up signalr on a farm. That specific implementation assumes you know the addresses of the machines in your farm but you could imagine a more dynamic implementation that adds/removes machines as needed (for azure like scenarios).
    David Fowler
    Thursday, September 01, 2011 11:33:32 AM UTC
    Don't really care about the post, but I wanted to say the redesign of your site looks good!
    Mike
    Thursday, September 01, 2011 6:08:43 PM UTC
    I wrote up how to use SignalR in an MVC3 application. Hope this helps some of you Razor devs out there. :)

    http://sergiotapia.com/2011/09/signalr-with-mvc3-chat-app-build-asynchronous-real-time-persistant-connection-websites/
    Thursday, September 01, 2011 6:54:53 PM UTC
    What browser versions will the client side work with? I can't find info on this (easily at least ;-) Will it work with IE6? Seriously.
    Friday, September 02, 2011 7:14:18 AM UTC
    @Tom Winter Any browser that supports xhr requests and a JSON parser. If there's no native json support in that browser the app just needs to include json2.js. That's about it.
    David Fowler
    Thursday, September 08, 2011 10:57:05 PM UTC
    HI Scott,

    Interesting stuff, as always ...
    But I wonder, what are the reasons that the web did not always used persistent connections (by persistent I mean, actually leave the socket open)?
    It seems web is designed to be stateless at all costs, why?
    What are the downsides of persistent connections (server side performance maybe?)

    Thanks,
    Ben.
    Sunday, September 11, 2011 10:16:20 AM UTC
    Hi Scott, why dont't we try something like this: http://developers.de/blogs/damir_dobric/archive/2011/09/11/microsoft-here-is-what-we-need.aspx
    Thursday, September 15, 2011 2:16:40 AM UTC
    I'm curious as to how the server contacts the browser. Is a constant connection left open between server and client?
    Saturday, September 17, 2011 9:00:18 PM UTC
    I am getting
    Message: 'undefined' is null or not an object error when I try to create chat object using high level example.

    I have added the SignalR using VS2010 package utility. JQuery, SignalR.js, and <script src="/signalr/hubs" type="text/javascript"></script> is added in my head tag.

    I have added Chat class as you instructed.

    With this, the logic fails @ var chat = $.connection.chat line.

    What could be a reason?
    Please let me know.
    Thanks,
    Samir
    Samir Patel
    Saturday, October 01, 2011 5:58:34 PM UTC
    Scott, this is awesome. I had been looking at options for comet based push technology for the application that I have been building (can't afford a commercial solution yet for a hobby project). Open source world has this already. It is nice to see that asp.net will finally have this.
    I am building my app in Azure so please make sure that this will work with multiple Azure web roles.
    John
    Thursday, October 13, 2011 4:42:26 AM UTC
    I tried the sample with Web Application Project and ASP.NET Website project.

    I found the code in ASP.NET Website project is not working

    var chat = $.connection.chat is null

    Can anybody tell me how to make it works on ASP.NET Website project?

    thank you.
    Anthony
    Thursday, October 13, 2011 3:29:35 PM UTC
    Thanks Scott!
    This is great good work and very easy to understand.

    One question though:

    How would you go about the situation where you want to be able to send a message across multiple websites (all in different assemblies) but accessible from only one location.

    For example: I have an assembly with the Chat.cs class that inherits from Hub, and that assembly is referenced by 3 other websites.

    I want to be able to send messages server-side to all those sites that use my Chat class.

    This is essentially to have a notification system that doesn't require constant pooling and instead when there is a new notification, we can simply push it to all applications.

    -Emmanuel
    Emmanuel
    Friday, November 11, 2011 11:44:16 PM UTC
    no go in ie6. could have worked using actionscript. don't really know why you didn't bother... also, the formatting of your blog is a bit off... why dont you fix it? other sites need the latest and greatest, but lets face it, yours doesn't
    flynnlike
    Saturday, November 12, 2011 12:17:50 AM UTC
    Ok Ok Ok (Denzel Voice). Much potential here. It's clean and standards based. I like it!

    Question...You say, "In the future things like WebSockets will be another way to solve this problem when it's baked." Are you guys saying your *not* using Websockets? If so, how exactly are you achieving the persistent connection?

    More importantly, does this only work in IE? I have to ask...
    Saturday, November 12, 2011 1:05:17 AM UTC
    We use WebSockets if it's available on client and server. Works best. We use LongPolling if it's not available.
    Saturday, November 12, 2011 4:57:35 AM UTC
    Being mean and pedantic, Scott please tag this article and your original article on SignalR written in August with 'SignalR' ;-).
    Saturday, November 12, 2011 5:41:46 AM UTC
    I try to install SignalR package (on VS 2010) but i get this error. http://pastebin.com/bG3ExHes What this error's reason?

    Thanks..
    Saturday, November 12, 2011 6:43:33 PM UTC
    Quick question, would SignalIR work on a shared hosting plan?
    Wednesday, November 16, 2011 4:42:50 AM UTC
    Can we assume that SignalR follows a same-origin policy for browser security?
    Mark
    Sunday, November 27, 2011 5:39:21 PM UTC
    SignalR really rocks!
    For all the beginners and intermediates,

    Here is a post on my blog on Real time Push Notifications with SignalR & PNotify http://www.msguy.com/2011/11/real-time-push-notifications-with.html
    Monday, November 28, 2011 4:08:36 AM UTC
    SignalR really rocks!
    For all the beginners and intermediates,

    Here is a post on my blog on Real time Push Notifications with SignalR & PNotify A HREF="http://www.msguy.com/2011/11/real-time-push-notifications-with.html
    Anil
    Friday, December 02, 2011 7:48:25 PM UTC
    Scott, you continue to blow my mind in terms of your depth and value in this field. I hope to one day return the favor but, until then, THANK YOU!
    Sunday, December 04, 2011 11:50:43 AM UTC
    Does it support Jsonp?
    Thursday, December 08, 2011 4:06:47 PM UTC
    $('#messages').append('<li>' + data + '</li>');


    Great - another way to introduce XSS bugs! :P
    Thursday, December 08, 2011 7:15:59 PM UTC
    Scott - are you sure? I've just tried with 1.6.2, and it executes the script:

    $("h1").append("Test<script>alert('hello')</script>")
    Thursday, December 08, 2011 7:21:35 PM UTC
    Richard - Ok, I'll look into it. I swear I though they tidied up this stuff for us. Thanks for trying!
    Thursday, December 08, 2011 7:30:55 PM UTC
    According to Karl Swedberg:
    All of jQuery's insertion methods use a domManip function internally to clean/process elements before and after they are inserted into the DOM. One of the things the domManip function does is pull out any script elements about to be inserted and run them through an "evalScript routine" rather than inject them with the rest of the DOM fragment. It inserts the scripts separately, evaluates them, and then removes them from the DOM.

    So the script will still be executed, even though it won't appear in the DOM.
    Thursday, December 08, 2011 7:40:24 PM UTC
    Hm, evalScript isn't the same as straight eval, I think.

    On an internal IM just now, Damien Edwards suggested this naive implementation:
    $(function () { 
    $.fn.appendHtml = function (content) {
    this.append($("<div/>").text(content).html());
    };
    $("#content").appendHtml("Hello <script>window.alert('hello');</script>");
    });
    Thursday, December 08, 2011 7:45:33 PM UTC
    That should do the trick. I've been using something similar in my own scripts:
    jQuery.htmlEncode = function(value) {
    return jQuery("<div/>").text(value).html();
    };
    Friday, December 09, 2011 1:27:25 PM UTC
    Scott,
    Isn't there some sort of open connection limit on windows server systems? Any idea how many active clients a typical server would actually be able to support?
    HighlyConcurrent
    Friday, December 09, 2011 11:16:49 PM UTC
    HighlyConcurrent - I'd have to ask David and Damien but I believe it's limited more by memory. It's in the tens to hundreds of thousands depending. I'll ask.
    Thursday, December 15, 2011 10:53:58 AM UTC
    Scott,
    One other question, when the infrastructure is using the long polling mechanism, does every 'push' back to the client result in the connection being terminated and re established?
    HighlyConcurrent
    Saturday, December 24, 2011 6:58:26 PM UTC
    For those interested, I found an excellent quick start and sample app here: http://blog.maartenballiauw.be/post/2011/12/06/Using-SignalR-to-broadcast-a-slide-deck.aspx Includes implementing a Console app as a SignalR client.
    Ken
    Thursday, December 29, 2011 10:30:22 PM UTC
    Dear Scott Hanselman

    I am following your guideline and everything seem good except the OnConnectedAsyncTask was not fire when I close tab or browser..???. I am using PersistentConnection and try to implement raw connection.
    How my App define disconnected clientID (or ConnectionID)...???.
    Thank for your help...
    hoanganh17b
    Saturday, December 31, 2011 12:51:45 AM UTC
    Dear Scott,

    After reading your post, I spent some time with this library but honestly, there are lots of things missing in SignalR to develop an enterprise level application. Consider a scenario, 10K active connections receiving a message each 5 secs. It fails.. Even though the number would be 2K. (TESTED)

    There are libraries around handling this task well under IIS and around 20-25K loads but obviously they are paid solutions.



    Sunday, January 01, 2012 1:26:47 AM UTC
    Tom - Specifics would help, but I'd recommend you try the version on GitHub, it's MUCH newer than the version on NuGet. I've personally seen it scale to hundreds of thousands of connections on one machine. Try it?
    Tuesday, January 03, 2012 6:16:07 PM UTC
    Tom - as Scott said, we've made many performance improvements in SignalR recently which have not been released in a new version on NuGet yet (due to a bunch of breaking changes, etc.). I've personally had it run >30K messages per second sustained on a single machine with these changes. I even managed to saturate a 1Gbps NIC on the load generator machine by upping the message size to 4KB with these rates.

    I encourage you to look at it again with the latest source. And please, if you have issues, provide as much detail as you can so that we might help address them.

    Thanks.
    Wednesday, January 04, 2012 12:41:11 AM UTC
    Damian, I'm trying it on a real life scenario (yes i tried the latest one); we have a website with thousands of real active users. I put my test app (signalR) as a hidden iframe on the main page (test app runs on an individual server) and monitoring the scenario ( each user receives a simple single message each 5 secs.) I afraid to say that it fails around approx. 2K of users) This is a 4 Core (8GB Ram) test server and only one test app is running. All the CPU's are almost at top and the system stucks at some point.

    PS: I think my test environment is good enough for the test case because I have made this test with another paid product with success.

    Thanks
    Wednesday, January 04, 2012 5:57:09 PM UTC
    Tom, sorry to hear you're having issues. If you care to email me at dedward@microsoft.com or come into the SignalR room on JabbR (http://jabbr.net/#/rooms/signalr) I'd be happy to dig a bit further.
    Thursday, February 02, 2012 3:56:12 PM UTC
    Hey Scott?

    Can you please update the line:

    RouteTable.Routes.MapConnection<myconnection>("echo", "echo/{*operation}");</myconnection>

    to this:

    RouteTable.Routes.MapConnection<MyConnection>("echo", "echo/{*operation}");

    Looks like your editor got a bit correction happy. When I was trying to run the low level connection, it totally threw me off at first.

    Thanks!
    Friday, February 03, 2012 12:40:52 PM UTC
    Hey Scott,

    Awesome post, you have inspired me to take a closer look into SignalR and it is impressive. Have already thrown together some cool little applications for it, loving it.

    I have seen a few posts around about implementing into CMS's such as Umbraco. Do you have any knowledge of how it fairs in more complex systems? For example Orchard, I only had a quick look at it but it seems that all of Orchards pre application executions bully SignalR out. I'm not quite sure how signalR works exactly but I assume it uses some pre application start hook to inject a http module which does the whole proxy client script generator. Possibly.

    Cant remember what my question was now ^^ Anyway, enjoyed the post, have a good one
    Friday, February 03, 2012 7:18:57 PM UTC
    This is great thank you. I am using SignalR with MVC4 internet application works fine with plan textarea; however, it would be great if SignalR works with rtf textarea such as tinyMCE editor then you get colorful collaboration.
    Zaia Youkhanna
    Friday, February 17, 2012 2:49:40 PM UTC
    I just upgraded my project from SignalR 0.35 to 0.40 version. Somehow, $.connection.hub.start(); is stop working. I see that the hub object is created, if I debug the .js file. When the code comes to $.connection.hub.start(); function, it does not initiate the connection.

    Nothing is changed in my code, just new references.

    I am using jquery 7.1 version, but version 0.35 was working pefrect with 7.1. Please advise.

    Here is my function:
    $.connection.hub.start(function () {
    alert("start function");

    chat.join()
    .fail(function (e) {
    addMessage(e, 'error');
    })
    .done(function (success) {
    if (success === false) {
    alert("returned false");
    }
    });
    });

    Thanks,
    Samir
    Samir Patel
    Wednesday, February 22, 2012 8:11:30 AM UTC
    @Samir maybe you're missing some assemblies that are now required in 0.4. Do you have SignalR.Hosting.AspNet? Maybe you're running into the assembly load failure on the server due to Newtonsoft.Json. Please asks question on the github issue list (https://github.com/SignalR/SignalR/issues).
    David Fowler
    Monday, February 27, 2012 12:34:53 PM UTC
    Hi Scott,
    Thank you for your great post.

    I am trying to use SignalR in a RESTfull architecture project with SL5.0 in client side. I could get it running and came up with the following quesitons:

    - Current SL is not compatible with SL5.0 because of using System.Threading.Tasks.SL4 assembly. However, when I remove this reference to use SL5.0 classes instead I get compile error because ConcurrentDictionary does not exist in in SL5.0, do you have any plan to support SL5.0 as well?

    - When do you think the SignalR.ScaleOut project will be completed?
    NB: If you are planning to release it soon then I won't have to implement it something similar myself.

    Thank you,
    Tuesday, February 28, 2012 10:14:34 AM UTC
    A quick update about my previous post!

    I just have a look at SignalR GitHub issues page and found out that the next release will be ready around one month later, and I hope the scaleout project will be completed then.
    Also, make an enquiry about SL5.0 support and David kindly answered that if the threading package that is used in SignalR will support SL5.0 then yes, but when it happens I don't know

    Thanks David
    Sunday, March 18, 2012 8:28:44 PM UTC
    @Hojjat - The scaleout version is live here: http://blogs.msdn.com/b/clemensv/archive/2012/02/13/signalr-powered-by-service-bus.aspx

    It runs on Azure with 4 nodes
    Friday, March 23, 2012 9:59:22 AM UTC
    Daft question - how does this work out in a web farm/cluster?

    Each web server's gonna have a different pool of clients that connected, and so events broadcast are only specific to a web server and its unique set of client connections, no? Not application-farm wide.
    Friday, March 23, 2012 10:27:35 AM UTC
    There are adapters for managing distributed state.
    Scott Hanselman
    Friday, April 20, 2012 12:57:25 AM UTC
    Scott check this out... its pretty cool!
    http://spmatt.wordpress.com/2012/04/12/harnessing-signalr-in-sharepoint/
    Monday, April 30, 2012 7:48:56 AM UTC
    @Chris Mankowski

    I meant Sql Server Scale Out, is there any plan to get it done?
    Monday, April 30, 2012 1:14:20 PM UTC
    Having struggled with writing a chat application in .net last year, can you tell me if signal-r will cope with a web farm environment?

    Thanks

    Paul
    Monday, April 30, 2012 5:59:01 PM UTC
    Paul and Hojjat - Yes, it has a pluggable state system.
    Tuesday, May 01, 2012 7:24:58 AM UTC
    Thanks for the info, Scott
    Is the pluggable state system documented anywhere?

    We'd like to use it for our web farm based project.

    Hojjat
    Tuesday, May 01, 2012 6:12:44 PM UTC
    super thanks. Will try out a small project to see what I think.

    Cheers

    Paul
    Tuesday, May 08, 2012 8:00:22 PM UTC
    Scott - the sample app seems to be down and/or broken.
    Erick T
    Tuesday, May 08, 2012 8:56:33 PM UTC
    Tuesday, May 08, 2012 9:18:57 PM UTC
    Excellent site. A lot of valuable details here. I am going to mailing it to 3 close friends ans also revealing in delicious. And of course, thanks for your sweat!
    Thursday, May 17, 2012 3:20:17 PM UTC
    Hi Scott,

    Regarding your 'I've personally seen it scale to hundreds of thousands of connections on one machine' quote. Would you see SignalR as good alternative to jQuery Ajax calls.
    Aust
    Monday, September 17, 2012 10:04:16 AM UTC
    Hi

    I'm trying to build a working example of the above, could you provide a step by step example, which method in the Global.asax should RouteTable.Routes.MapConnection<myconnection>("echo", "echo/{*operation}");</myconnection> go in ? for example ?
    Robert Everett
    Tuesday, October 23, 2012 11:51:22 AM UTC
    Good work buddy. But let's say that I only want to do this using long-polling. Is it possible to write something from scratch with less code to do the same thing? I mean, do you have any reference to create a mini-SignalR?
    Tuesday, November 20, 2012 5:48:42 PM UTC
    Hi David,
    Lets say that I want to use SignalR in VS2010 to create a chatroom application.
    When I'm using NuGet I'm not finding SignalR but a plethora of SignalR.* packages. I'm confused which one to use?Hence I don't want to use NuGet to download and include in my project. All I want is to add some dlls and JS files at most to my application and then use SignalR. In that case what would be the dlls/JS file which I would need?
    Can you please help me out?
    Thanks
    irshad
    Sunday, December 09, 2012 9:58:19 PM UTC
    私はモンクレールのダウン街で最高のジャケットを持っていると思う。私は本当にモンクレールが好きで、私はできる、私はできるだけ多くの得ることがしたい。 :D
    モンクレール ダウン
    rock
    Monday, December 10, 2012 1:31:03 PM UTC
    Hi Scott,

    I am hoping to use SignalR in a self hosted Windows Service.

    This Windows Service is supposed to monitor an external system and publish changes to JS clients as and when they happen.

    My question is, is there a way to secure the SignalR endpoint hosted within the Windows Service? For example, any one finding out this Url could write a simple app to start receiving notifications. If I hosted these endpoints within IIS, I could use Windows Authentication/Authorisation to restrict access.

    Apologies if this is a very easy thing to do, but I am new to SignalR dev.

    Thanks very much.

    Suneth
    Suneth
    Friday, December 28, 2012 3:26:25 AM UTC
    It doesn't work for me , keep getting

    Uncaught TypeError: Object #<Object> has no method 'send'
    Dinesh Dharmawardena
    Comments are closed.

    Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.