SignalR Isn’t Working on Samsung Galaxy 3

14/05/2013

I know you think the title is wired, because what is the relation between SignalR (WebSockets) and a specific device such as Samsung Galaxy 3?

ASP.NET SignalR is a new library for ASP.NET developers that makes it incredibly simple to add real-time web functionality to your applications. What is "real-time web" functionality? It’s the ability to have your server-side code push content to the connected clients as it happens, in real-time.

While working on a project working with SignalR we faced a problem, the following code start the connection with the hub but the following code isn’t working, neither success or failed message appear.

$.connection.hub.start().done(function () {
    alert("Connection Working!");
}).fail(function (e) {
    alert("Connection Isn’t Working… :-( ");
});

Tried to debug the code I didn’t understand why the fail function isn’t invoked… I tired to change the transport layer to polling as part of the testing and it works……

connection.start({ transport: ‘longPolling’]})

I said to my self this is strange, After all Galaxy 3 supports should WebSockets and beside that this what SignalR should do if the browser isn’t supporting a specific transport layer.

From this part of I’ve understand the problem related to SignalR but still didn’t understand why that same code works on Nexus 4 and some other Android devices.

So I made the following test, I’ve open the Galaxy 3 browser and navigate to “http://www.websocket.org/echo.html” to check support for WebSockets , and surprise something isn’t working as it should – The log field didn’t showed anything (Again on different devices this works just fine).

image

So first thing I’ve modified jquery.signalR.js file, I’ve added a time out around the WebSockets connection, this solved the problem…

Then after a short search I found this Bug: Persistent Connection fails with IIS8 on Android Stock Browser

And this guy add his fix for the problem here – https://github.com/SignalR/SignalR/commit/6d892a3cdeb94099ed06b978ba66ec13fce521ae

You can download the fix and implementing your own timeout around the connection start.

Enjoy

Add comment
facebook linkedin twitter email

Leave a Reply