Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignalR on mobile web?

I'm evaluating SignalR technology for use in our new product (mobile web application for the broad audience, among other things it needs a real-time chat on some pages).

I've followed the guide to create a very basic chat demo. Then I deployed the demo on my IIS, and started chatting to myself. All clients were on the same WiFi network.

Desktop browsers worked more or less OK.

However, Safari on iOS 4.2, and IE on WP7.10 - they both sucked. Sometimes nothing happened when I pressed the "post" button. Sometimes outgoing messages were sent OK to the desktop firefox, however there was no incoming messages.

Maybe I'm missing something obvious? Maybe I need jquery mobile instead of the normal one? Maybe I should just tune the IIS/web.config/whatever, and the SignalR will flourish and start to work flawlessly even through the crappy mobile internet?

Or does it mean that since it doesn't work even while on WiFi within a single hop from the web server, I should throw SignalR away and just write some JavaScript to poll a JSON endpoint for new messages?

Thanks in advance!

like image 452
Soonts Avatar asked Mar 01 '12 00:03

Soonts


1 Answers

I have been developing an app with phonegap (that means that uses the Safari browser) and SignalR for Android and IPhone. The major issue I had was with iOS 6.x because SignalR did not connect with default config. I have found a workaround for that and I had explained it here. Let me know if you find it useful.

This code will simulate a connect, check for messages, disconnect and wait 5 secs to solve the iOS issue.

In js add

$.connection.hub.start({ transport: 'longPolling' }).done(function (myHubConnection) { });

and in Application_Start() add

GlobalHost.Configuration.ConnectionTimeout = TimeSpan.FromSeconds(1);
Microsoft.AspNet.SignalR.Transports.LongPollingTransport.LongPollDelay = 5000;
RouteTable.Routes.MapHubs();
like image 168
Ariel Erlijman Avatar answered Oct 01 '22 11:10

Ariel Erlijman