Soonts
Soonts

Reputation: 21956

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!

Upvotes: 8

Views: 5082

Answers (2)

Ariel Erlijman
Ariel Erlijman

Reputation: 372

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();

Upvotes: 6

lurkerbelow
lurkerbelow

Reputation: 719

Not all mobile browsers (e.g. android, opera mini) support websockets. You'll find a nice chart of supporting browsers at http://www.hanselman.com/blog/YourUsersDontCareIfYouUseWebSockets.aspx

Upvotes: 0

Related Questions