Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignalR working in browser not in app

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?

like image 234
Gal Ziv Avatar asked Oct 19 '22 09:10

Gal Ziv


2 Answers

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.

like image 134
Gal Ziv Avatar answered Oct 22 '22 00:10

Gal Ziv


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!

like image 24
Kenneth Li Avatar answered Oct 22 '22 01:10

Kenneth Li