Intermittent “The request was aborted: Could not create SSL/TLS secure channel.” solved

When trying to establish a TLS connection, the above message was seen intermittently. Other messages included “The underlying connection was closed: The connection was closed unexpectedly.”

At the same time these apparent comms errors occurred, looking in the System event log showed a lot of Schannel EventCode 36888 with the message:

"The following fatal alert was generated: 80. The internal error state is 301."

The explanation for code 80 from is:

An internal error unrelated to the peer or the correctness of the protocol makes it impossible to continue, such as a memory allocation failure. The error is not related to protocol. This message is always fatal.

The key to solving this was memory allocation failure, it was not the external system but internal memory pressure that was causing the problem. Fixing the memory issue also resolved the communications issues.

Unfortunately this is just one cause of this error message, other times it has turned out to be the external system in which case System.Net tracing could help:

(At the time, one of the external systems had upgraded a version of Apache that had an issue in mod_proxy_http).

BBC identifies a growing concern over inappropriate Internet content in 2013!

Just spotted this article in October 2013 saying that Google’s move to add parental controls to chrome “… comes after growing concerns over inappropriate content children can be exposed to online.”

I believe the concerns have been there for a number of years and that Google is actually very late in adding such controls that other browsers have had for a long time (e.g. Internet Explorer since at least 2007, long before the BBC appears to have had any concerns over Internet content).

The article implies Google are simply reacting to changing times rather than playing catch-up.

Unit testing DelegatingHandler

The DelegatingHandler in the MVC 4 beta Web API is not particularly easy to test due to the inheritance dependency on DelegatingHandler and the use of overridden protected methods. All is not lost though, by using the following pattern you can achieve testability of the logic with subtle changes to your existing DelegatingHandler and without breaking the Russian Doll pattern.

Create a delegate as follows:

public delegate Task<HttpResponseMessage> BaseSendAsyncDelegate(HttpRequestMessage request, CancellationToken cancellationToken);

Changing your DelegatingHandler to the following (note you’ll also need to add InternalsVisibleTo attribute for your unit test to see the handler):

public class MyTestableDelegatingHandler : DelegatingHandler
    internal Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken, BaseSendAsyncDelegate baseSendAsync)


        // Your before logic
        // …
return baseSendAsync(request, cancellationToken).ContinueWith(
            task =>
                    HttpResponseMessage response = task.Result;
                    // Your after logic
return response;
    protected override System.Threading.Tasks.Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
        // Don’t put anything else in this method
return this.SendAsync(request, cancellationToken, (r, c) => base.SendAsync(r, c));


Now the logic can be called without the overhead of the DelegatingHandler as follows:

public void MyTest()
    MyTestableDelegatingHandler logic = new MyTestableDelegatingHandler();
    HttpRequestMessage requestMessage = new HttpRequestMessage();

    Task<HttpResponseMessage> result = logic.SendAsync(
        new CancellationToken(false),
        (rm, ct) =>

                // Do some Asserts in here for any “Before” logic

                // This simulates what the inner handler (or ultimately the controller) would return
                var task = new Task<HttpResponseMessage>(() => new HttpResponseMessage(HttpStatusCode.OK));
                return task;

    HttpResponseMessage resultMessage = result.Result;
    var status = resultMessage.StatusCode;
    // Do Asserts here for any “After” logic

MVC4 Web API–REST Sub-resources

To create sub-resources (e.g. /books/1/authors) in the Web API that shipped with MVC beta 4, you can create a “SubResourceControllerFactory” to mangle the controller name to include a sub controller as follows:

public class SubResourceControllerFactory : DefaultHttpControllerFactory
    public SubResourceControllerFactory(HttpConfiguration configuration) : base(configuration)

    public override System.Web.Http.Controllers.IHttpController CreateController(System.Web.Http.Controllers.HttpControllerContext controllerContext, string controllerName)
        if (controllerContext.RouteData.Values.ContainsKey("subcontroller"))
            return base.CreateController(controllerContext, controllerName + controllerContext.RouteData.Values["subcontroller"]);

        return base.CreateController(controllerContext, controllerName);

This factory can be instantiated using a custom IDependencyResolver that’s looking for a type of IHttpControllerFactory, for example in Global.asax.cs (Application_Start):

GlobalConfiguration.Configuration.ServiceResolver.SetResolver((type) =>
        if (type == typeof(IHttpControllerFactory))
            return new SubResourceControllerFactory();

Finally you create a route similar to:

routeCollection.MapHttpRoute("SubController", "api/{controller}/{id}/{subcontroller}/{subId}", new { subId = RouteParameter.Optional })

Free iPad/iPod advertising

Thought I’d start to collate the news articles where the Media give free advertising to iPads that could easily have been any other device when covering disrelated or non-iPad specific news. Or it’s added in the headline when it is as incidental to the story as a common activity. I can see the irony in this blog post adding yet more coverage though 🙂

Scottish independence: Braveheart or iPad?
Seriously BBC most people can picture what £500 is and don’t need a reference to a product most people don’t own – specifically one made by a single company who don’t need the free advertising.

Glass aeroplanes and iPads on the way, say boffins

The body of the article doesn’t even mention iPads or any other tablet device but hey, why not shove it in the title.

Giffords standing up and using iPad

There are probably a number of other things she’s managed to do too but without such blatant product placement.

Has the iPod made us anti-social?

Not quite in the same vein but recent article on BBC News seems to suggest Apple invented MP3 players:

“The personal stereo has been around for three decades. But the iPod – by far the
biggest selling MP3 player – has taken it well beyond the limitations of its
bulky earlier equivalents”

What??! I’m not saying the iPod wasn’t more successful but they did not fill the gap between today’s MP3 players and yesterdays Walkmans. I owned a Sony lighter sized MP3 player way before the iPod came out … well I say MP3 it actually natively used ATRAC and the software wouldn’t install on latest version of Windows… last Sony product I ever bought…. maybe I’ve digressed too far.