SignalR working in browser not in app

3.6k views Asked by At

I have an app which uses signalR when I try it in the browser it works properly. of course the connection is to an absolute URLץ

When I deploy the app to an android device it doesn't work. I connected Chrome to do remote debug to the app's webview and I can see the network tab.

The negotiation is working and I can see result but besides that nothing works.

I assume it might be a permission\configuration issue since it works on browser.

Which steps should I take to make this work?

2

There are 2 answers

4
Gal Ziv On BEST ANSWER

So I managed to make it work. Since I'm doing my cross-domain communication using JSONP i wanted to do the same with signalR.

In my browser it worked properly but when compiled to APK and ran on device it didn't work.

changing signalR to use CORS and not jsnop solved the issue.

3
Kenneth Li On

possible answer:

first of all, I'll assume that in browser means you put the client html file in a Web Server. e.g. www.example.com/index.html

then the signalr Server hub is also in www.example.com

after you deploy, cordova put the index.html inside the Android phone or iPhone, then it becomes a cross Domain call, so you need to enable Cors to let it works!