2.0.0-beta2

@DamianEdwards DamianEdwards released this Jul 2, 2013 · 988 commits to dev since this release

Overview

iOS and Android support via MonoTouch and MonoDroid (Xamarin)

Added support for MonoTouch and MonoDroid components. For more information on how to use them see Using Xamarin Components.
These components will ship in the Xamarin Store when SignalR 2.0 is RTW.

Portable .NET Client Library

Added a portable .NET client that supports the following platforms

  • .NET 4.5
  • Silverlight 5
  • WinRT (.NET for Windows Store Apps)
  • Windows Phone 8

Self hosting package

SignalR now includes a NuGet package (Microsoft.AspNet.SignalR.SelfHost) to make self hosting easier to get started.
Installing this package via NuGet will show a readme.txt for getting started. For more information on self hosting your SignalR application see
http://www.asp.net/signalr/overview/getting-started/tutorial-signalr-self-host.

Backwards compatible server support

In the past, the SignalR client and server needed to be the exact same version to work. This made it hard to update servers
for applications with thick/native mobile clients.
SignalR now supports the ability to use older clients with newer servers. This allows applications to update the server side and not have to worry about client breaking.

NOTE: SignalR does NOT support newer clients with older servers.

Breaking Changes

.NET 4.5 only (Server Side)

SignalR 2.0 only supports .NET 4.5 on the server now so projects that are tied to .NET 4.0 will have to keep using SignalR 1.1.

Removal of Packages/Assemblies/APIs

The following assemblies/APIs have been deleted:

  • Microsoft.AspNet.SignalR.Owin
  • Microsoft.AspNet.SignalR.SystemWeb
    • RouteTable.Routes.MapHubs()
    • RouteTable.Routes.MapConnection()
    • IRequest.GetHttpContext()

The OWIN dependency has been merged into Microsoft.AspNet.SignalR.Core.

See below for replacements for the deleted APIs above.

Migrating your application from 1.x to 2.0

After updating to SignalR 2.0 beta2 you should see the following compilation errors:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Routing;
using System.Web.Security;
using System.Web.SessionState;
using Microsoft.AspNet.SignalR;

namespace MyApplication
{
    public class Global : System.Web.HttpApplication
    {
        protected void Application_Start(object sender, EventArgs e)
        {
            RouteTable.Routes.MapHubs();
            RouteTable.Routes.MapConnection<MyConnection>("echo", "/echo");
        }
    }
}
'System.Web.Routing.RouteCollection' does not contain a definition for 'MapHubs' and no extension method 
'MapHubs' accepting a first argument of type 'System.Web.Routing.RouteCollection' could be found 
(are you missing a using directive or an assembly reference?)
'System.Web.Routing.RouteCollection' does not contain a definition for 'MapConnection' and no extension method 
'MapConnection' accepting a first argument of type 'System.Web.Routing.RouteCollection' could be found 
(are you missing a using directive or an assembly reference?)

To migrate an existing SignalR 1.x project to 2.0 do the following:

  • Remove calls to RouteTable.Routes.MapHubs() and RouteTable.Routes.MapConnection() in Global.asax.
  • Add a Startup.cs file to the root your project with the following content:
using Microsoft.Owin;
using Owin;
using MyWebApplication;

namespace MyWebApplication
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            // Any connection or hub wire up and configuration should go here
            app.MapHubs();  
            app.MapConnection<MyConnection>("/echo");
        }
    }
}

Website projects

For Website projects, add the following config section to the root web.config:

<appSettings>
  <add key="owin:AppStartup" value="MyWebApplication.Startup, App_Code"/>
</appSettings>

If you still see the following errors after the above steps:

The call is ambiguous between the following methods or properties:
'Owin.OwinExtensions.MapConnection<T>(Owin.IAppBuilder, string, Microsoft.AspNet.SignalR.ConnectionConfiguration)' and 
'Owin.OwinExtensions.MapConnection<T>(Owin.IAppBuilder, string, Microsoft.AspNet.SignalR.ConnectionConfiguration)'

The reason is "Microsoft.AspNet.SignalR.Owin" has been deprecated. You must uninstall the NuGet Package from your project.

IRequest.GetHttpContext() replacement

All dependencies on System.Web were removed. If your existing project was using the GetHttpContext extension method then you will need to restore this functionality by adding a new class to your project with the following content:

using System.Web;
using Microsoft.AspNet.SignalR;

namespace Microsoft.AspNet.SignalR
{
    public static class SystemWebExtensions
    {
        public static HttpContextBase GetHttpContext(this IRequest request)
        {
            object value;
            if (request.Environment.TryGetValue(typeof(HttpContextBase).FullName, out value))
            {
                return (HttpContextBase)value;
            }

            return null;
        }
    }
}

Server sent events has known issues on Silverlight

Messages are delayed when using server sent events on silverlight. To force long polling use the following:

connection.Start(new LongPollingTransport());

.NET client callback fails to fire

If your .NET client callback suddenly stops working, it might be because the callback has
the wrong number of arguments:

Server:

public class Chat : Hub
{
    public void Send(string message)
    {
        Clients.All.addMessage(message);
    }
}

Client:

var connection = new HubConneciton("http://localhost:8080/myapp");
var proxy = connection.CreateHubProxy("Chat");

proxy.On("addMessage", () => 
{
    Console.WriteLine("Called!");
});

The wrong number of arguments are being passed to the method. To see the exception, turn logging on:

connection.TraceWriter = Conosle.Out;

To resolve the issue, specify the correct number of arguments on the client side:

proxy.On<string>("addMessage", message => 
{
    Console.WriteLine("Called with {0}", message);
});

Features

  • Update to JSON.NET 5 (#1932)
  • Make a .NET portable class library client (#1907)
  • Send init message prior to triggering connect (#1889)
  • Allow to Send Json Strings without duplicate Serialization (#1546)

Bugs Fixed

  • JS client foreverFrame run into script error when immediately start->stop->start connection (#2190)
  • JS client immediately start->stop->start connection causes Hub event handler added again again (#2187)
  • When the SSE transport is aborted on the client, it tries to reconnect (#2180)
  • start-stop-start long polling results on a stream of poll requests (#2160)
  • Update to HttpClient PCL RTW (#2109)
  • Remove dependency on Microsoft.Owin.Security.DataProtection.DpapiDataProtectionProvider (#2104)
  • Reconnects hang when WebSocket timed out and fallback was used (#2096)
  • Run all functional tests with fake scaleout message bus. (#2085)
  • when specify uiCulture in web.config, SignalR doesn't load the resource string for the specified locale (#2077)
  • When change from using scale-out to not use scale-out, cursors value could change unexpectedly which cause group not working anymore (#2061)
  • WP8 client fails on SSE and does not fallback to LongPolling (#2028)
  • Problem with self host Server - Client on Mac (Mono) (#1999)
  • Skip SSE in Silverlight & WP clients (#1995)
  • Disable KeepAlive properly for Long Polling for the .NET client (#1960)
  • System.ArgumentOutOfRangeException on the client side when hub invokes the callback (#1958)
  • JS SSE transport: if you call connection.stop() before the connection is opened, TypeError (#1873)
  • consider including connect url for longPolling etc in .Net client trace (#1760)
  • IE 10 Web Sockets Security Error when simultaneous connection limit reached (#1744)