SignalR 0.5.1 Released

Here comes another exciting release of SignalR. This release has some new features that you can take advantage of as well as a few bug fixes. Let’s go over the big changes for this release.

Windows 8 Client support

With the Windows 8 Release Preview, we’ve finally added a new client to support “.NET for Metro Style Apps” and also made some fixes so that SignalR’s JavaScript client works with WinJS.

WebSocket Support

Previously, websocket support required a separate package, now it’s built into SignalR. The ASP.NET host is the only one that supports this and that’s only when running an application targeting .NET 4.5 on IIS8.

Improved Cross Domain Support

We introduced cross domain support for SignalR in 0.5. In this release we’ve improved that support in a few ways:

  1. All SignalR end points are CORS enabled by default. This means you can point the JavaScript client to the endpoint and have it just work without having to manually add the cors header to web.config.
  2. SignalR will choose automatically negotiate the transport so there’s no need to specify it or the xdomain flag (which is no longer supported).
$.connection.hub.url = 'http://localhost:8081/signalr;

$.connection.hub.start();

The above code is all you need to do to connect to a remote server using SignalR.

Connection State Changes

A SignalR connection has always been a black box to the user and this made it hard to detect changes in the underlying connection state. We’ve exposed a new stateChanged event in the JavaScript and .NET clients. This allows you to listen for state changes and react to them in different ways. Here’s an example that shows the user a message if the connection went into a reconnecting state and didn’t recover after 10 seconds:

var chat = $.connection.chat;
var timeout = null;
var
interval = 10000;

chat.addMessage =
function
(msg) {
    $(
'#messages').append('<li>' + msg + '</li>'
);
};

$.connection.hub.stateChanged(
function
(change) {
   
if
(change.newState === $.signalR.connectionState.reconnecting) {
        timeout = setTimeout(
function
() {
            $(
'#state').css('backgroundColor', 'red'
)
                        .html(
'The server is unreachable...'
);
        }, interval);
    }
   
else if
(timeout && change.newState === $.signalR.connectionState.connected) {
        $(
'#state').css('backgroundColor', 'green'
)
                        .html(
'The server is online'
);

        clearTimeout(timeout);
        timeout =
null;
    }
});

$.connection.hub.start();

When the connection state changes to reconnecting, we set a 10 second timer, if the state doesn’t change to “connected” in those 10 seconds then we set the message to say the server is unreachable. When the connection comes back online (i.e the state the connected), we set the message, “The server is online”.

This feature should give app developers a chance to deliver nicer user experiences when for clients on crappy connections or when servers go down unexpectedly. We’ll continue to improve this in the future.

Clean Disconnect

Normally when a connection is broken between the browser and server, the underlying http request takes some time to go away (you can use fiddler to see this). In 0.5.1 we’ve added the ability for the client to send a packet to the server whenever a connection is stopped or the browser is closed. This means disconnect will fire more immediately on browser close or on page refreshes.

Hubify.exe

It’s not a nuget package but will be in the http://chocolatey.org/ gallery soon. For now, you can run get hubify.exe by building https://github.com/SignalR/SignalR/tree/master/SignalR.ProxyGenerator. You can run this against your project’s bin directory or a remote url to generate or download the hubs.js file that would normally be dynamically generated when referencing the magic script url:

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

You can add this to a post build event in your project to generate the file a build time so that you can take advantage of http caching when you deploy your application (See an example here).

Keep Alive

Keep alive is now on by default and is set to 30 seconds.

Those are the highlights, view the release notes for more information.

Get it on NuGet today!

Published Sunday, June 10, 2012 11:17 PM by davidfowl

Comments

# re: SignalR 0.5.1 Released

Monday, June 11, 2012 5:14 AM by koistya

Cool. Are there known issues when deployed in a cloud environment?

# re: SignalR 0.5.1 Released

Monday, June 11, 2012 5:22 PM by davidfowl

@koistya Which cloud, there's alot.

# re: SignalR 0.5.1 Released

Monday, June 11, 2012 6:59 PM by koistya

Windows Azure

# re: SignalR 0.5.1 Released

Wednesday, June 13, 2012 2:56 PM by diegobu

I have a client site (with only the jquery and signalr scripts) and server site (signalr server, hubs, etc)

i have to add jQuery.support.cors = true; on the client site to get working on IE9,  What I missed?

# re: SignalR 0.5.1 Released

Thursday, June 14, 2012 3:38 AM by davidfowl

@diegobu check the mode IE is running in (i.e. Browser mode and Documents mode). Check that they are both IE9

# re: SignalR 0.5.1 Released

Monday, June 18, 2012 4:05 AM by Varun Maggo

Updated to latest version and works good!

# re: SignalR 0.5.1 Released

Tuesday, June 19, 2012 5:32 AM by goce

have issues on live site, in dev environment is working perfect, but on the live site, the chat stops working after some time(1 minute), without any message in console or in the $.connection.hub.stateChanged event, i think it happens when the transport goes to long polling, that can be causing this issues, thanks

# re: SignalR 0.5.1 Released

Monday, July 2, 2012 9:15 AM by Miha Markic

Checked the "connection lost..." feature and it works fine on stock browser, Firefox and Chrome on Android.