barakataboujreich opened a new issue #944: URL: https://github.com/apache/cordova-ios/issues/944
## Description hello guys, we are trying to upgrade cordova-ios to 6.1.0 since uiwebview is deprecated and wont be accepted on stores anymore. we had everything working on uiwebview. i managed to make XMLHttpRequest work with null origin, and we are able to make api calls again. but we are facing a problem with signalR, it seems that it's not able to connect. i am not able to figure out the problem. ### What is expected to happen? signalR to connect normally to the server. ### What does actually happen? signal R isn't able to connect. ## Information for a start i got this call: ``` Summary URL: http://192.168.47.105:55554/signalr/connect?transport=serverSentEvents&clientProtocol=1.5&connectionToken=OC0LMC6PzDP%2BbksoG4PF3OlmAX6ScrTdg3yOxtaZFnHAspQjvqfFpDSCIWJGLNME%2FlCUg86Vpg1h12VOoR2uB0b2LyBVPbsRU%2BVo%2BNONkFIgdFfNcVahRec6xURdjwMs&connectionData=%5B%7B%22name%22%3A%22kindoohub%22%7D%5D&tid=9 Status: 200 OK Source: Network Request Accept: text/event-stream Cache-Control: no-cache Origin: null User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 Pragma: no-cache Response Content-Type: text/event-stream Access-Control-Allow-Origin: null Pragma: no-cache Access-Control-Allow-Methods: GET, POST Expires: -1 Transfer-Encoding: Identity Access-Control-Allow-Headers: Content-Type Cache-Control: no-cache Date: Wed, 15 Jul 2020 12:37:22 GMT Access-Control-Allow-Credentials: true X-Content-Type-Options: nosniff X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Server: Microsoft-IIS/7.5 Query String Parameters transport: serverSentEvents clientProtocol: 1.5 connectionToken: OC0LMC6PzDP+bksoG4PF3OlmAX6ScrTdg3yOxtaZFnHAspQjvqfFpDSCIWJGLNME/lCUg86Vpg1h12VOoR2uB0b2LyBVPbsRU+Vo+NONkFIgdFfNcVahRec6xURdjwMs connectionData: [{"name":"kindoohub"}] tid: 9 ``` although the status is 200 ok, it is marked in red, and the preview shows an error occured trying to load the resource. then i get this in console: `XMLHttpRequest cannot load http://192.168.47.105:55554/signalr/abort?transport=serverSentEvents&clientProtocol=1.5&connectionToken=OC0LMC6PzDP%2BbksoG4PF3OlmAX6ScrTdg3yOxtaZFnHAspQjvqfFpDSCIWJGLNME%2FlCUg86Vpg1h12VOoR2uB0b2LyBVPbsRU%2BVo%2BNONkFIgdFfNcVahRec6xURdjwMs&connectionData=%5B%7B%22name%22%3A%22kindoohub%22%7D%5D.` now this is my config.xml: ``` <?xml version='1.0' encoding='utf-8'?> <widget id="{{myappid}}" version="3.6.3" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0"> <name>kindoo</name> <description> kindoo is an application that transforms any electric lock to a smart lock </description> <author email="[email protected]" href="http://codegears.com"> Code gears </author> <content src="index.html" /> <preference name="permissions" value="none" /> <preference name="orientation" value="default" /> <preference name="target-device" value="universal" /> <preference name="fullscreen" value="true" /> <preference name="webviewbounce" value="true" /> <preference name="prerendered-icon" value="true" /> <preference name="stay-in-webview" value="false" /> <preference name="ios-statusbarstyle" value="black-opaque" /> <preference name="detect-data-types" value="true" /> <preference name="exit-on-suspend" value="false" /> <preference name="ShowSplashScreenSpinner" value="false" /> <preference name="AutoHideSplashScreen" value="false" /> <preference name="disable-cursor" value="false" /> <preference name="android-minSdkVersion" value="14" /> <preference name="android-installLocation" value="auto" /> <preference name="DisallowOverscroll" value="true" /> <preference name="StatusBarOverlaysWebView" value="false" /> <preference name="StatusBarBackgroundColor" value="#142515" /> <preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" /> <gap:plugin name="org.apache.cordova.battery-status" /> <gap:plugin name="org.apache.cordova.camera" /> <gap:plugin name="org.apache.cordova.media-capture" /> <gap:plugin name="org.apache.cordova.console" /> <gap:plugin name="org.apache.cordova.contacts" /> <gap:plugin name="org.apache.cordova.device" /> <gap:plugin name="org.apache.cordova.device-motion" /> <gap:plugin name="org.apache.cordova.device-orientation" /> <gap:plugin name="org.apache.cordova.dialogs" /> <gap:plugin name="org.apache.cordova.file" /> <gap:plugin name="org.apache.cordova.file-transfer" /> <gap:plugin name="org.apache.cordova.geolocation" /> <gap:plugin name="org.apache.cordova.globalization" /> <gap:plugin name="org.apache.cordova.inappbrowser" /> <gap:plugin name="org.apache.cordova.media" /> <gap:plugin name="org.apache.cordova.network-information" /> <gap:plugin name="org.apache.cordova.splashscreen" /> <gap:plugin name="org.apache.cordova.vibration" /> <platform name="ios"> <allow-intent href="itms:*" /> <allow-intent href="itms-apps:*" /> <allow-navigation href="http://192.168.47.105:55554/*" /> <allow-navigation href="http://www.{{mydomainname}}.tech/*" /> <allow-navigation href="http://*.{{mydomainname}}.tech/*" /> <allow-navigation href="https://www.{{mydomainname}}.tech/*" /> <allow-navigation href="https://*.{{mydomainname}}.tech/*" /> <icon height="20" src="res/icon/ios/icon-20.png" width="20" /> <icon height="40" src="res/icon/ios/[email protected]" width="40" /> <icon height="60" src="res/icon/ios/[email protected]" width="60" /> <icon height="29" src="res/icon/ios/icon-29.png" width="29" /> <icon height="58" src="res/icon/ios/[email protected]" width="58" /> <icon height="87" src="res/icon/ios/[email protected]" width="87" /> <icon height="40" src="res/icon/ios/icon-40.png" width="40" /> <icon height="80" src="res/icon/ios/[email protected]" width="80" /> <icon height="120" src="res/icon/ios/[email protected]" width="120" /> <icon height="50" src="res/icon/ios/icon-50.png" width="50" /> <icon height="100" src="res/icon/ios/[email protected]" width="100" /> <icon height="57" src="res/icon/ios/icon-57.png" width="57" /> <icon height="114" src="res/icon/ios/[email protected]" width="114" /> <icon height="120" src="res/icon/ios/[email protected]" width="120" /> <icon height="180" src="res/icon/ios/[email protected]" width="180" /> <icon height="72" src="res/icon/ios/icon-72.png" width="72" /> <icon height="144" src="res/icon/ios/[email protected]" width="144" /> <icon height="76" src="res/icon/ios/icon-76.png" width="76" /> <icon height="152" src="res/icon/ios/[email protected]" width="152" /> <icon height="167" src="res/icon/ios/[email protected]" width="167" /> <icon height="1024" src="res/icon/ios/icon-1024.jpg" width="1024" /> <splash src="res/screen/ios/Default@2x~iphone~anyany.png" /> <splash src="res/screen/ios/Default@2x~iphone~comany.png" /> <splash src="res/screen/ios/Default@2x~iphone~comcom.png" /> <splash src="res/screen/ios/Default@3x~iphone~anyany.png" /> <splash src="res/screen/ios/Default@3x~iphone~anycom.png" /> <splash src="res/screen/ios/Default@3x~iphone~comany.png" /> <splash src="res/screen/ios/Default@2x~ipad~anyany.png" /> <splash src="res/screen/ios/Default@2x~ipad~comany.png" /> <edit-config file="*-Info.plist" mode="merge" target="NSBluetoothPeripheralUsageDescription"> <string>Bluetooth is needed to communicate with KINs</string> </edit-config> <edit-config file="*-Info.plist" mode="merge" target="NSBluetoothAlwaysUsageDescription"> <string>Bluetooth is needed to communicate with KINs</string> </edit-config> <edit-config file="*-Info.plist" mode="merge" target="NSCameraUsageDescription"> <string>Camera is needed to take profile picture</string> </edit-config> <edit-config file="*-Info.plist" mode="merge" target="NSMicrophoneUsageDescription"> <string>Microphone is needed to take a video</string> </edit-config> <edit-config file="*-Info.plist" mode="merge" target="NSPhotoLibraryUsageDescription"> <string>Library is needed to upload profile picture</string> </edit-config> <edit-config file="*-Info.plist" mode="merge" target="NSLocationAlwaysUsageDescription"> <string>Location is needed to communicate with KINs</string> </edit-config> <edit-config file="*-Info.plist" mode="merge" target="NSLocationWhenInUseUsageDescription"> <string>Location is needed to communicate with KINs</string> </edit-config> </platform> <access origin='*' allows-arbitrary-loads-for-media='true' allows-arbitrary-loads-in-web-content='true' allows-local-networking='true' /> <allow-navigation href="*" /> <allow-intent href="http://*/*" /> <allow-intent href="https://*/*" /> <allow-intent href="tel:*" /> <allow-intent href="sms:*" /> <allow-intent href="mailto:*" /> <allow-intent href="geo:*" /> <feature name="CDVWKWebViewEngine"> <param name="ios-package" value="CDVWKWebViewEngine" /> <preference name="scheme" value="http" /> <preference name="hostname" value="192.168.47.105" /> </feature> </widget> ``` i have these customheaders in my server Web.config ``` <customHeaders> <add name="Access-Control-Allow-Headers" value="Content-Type" /> <add name="Access-Control-Allow-Methods" value="GET, POST" /> <add name="Access-Control-Allow-Credentials" value="true" /> </customHeaders> ``` and i have this code in Global.asax.cs to handle the null origin: ``` protected void Application_BeginRequest(object sender, EventArgs e) { if (Context.Request.UrlReferrer != null) HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", Context.Request.UrlReferrer.GetLeftPart(UriPartial.Authority)); //browser else HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "null"); //cordova } ``` and for my startup: ``` public class Startup { public void Configuration(IAppBuilder app) { try { string redisIP = ConfigurationManager.AppSettings["RedisIP"].ToString(); int redisPort = int.Parse(ConfigurationManager.AppSettings["RedisPort"].ToString()); GlobalHost.DependencyResolver.UseRedis(redisIP, redisPort, null, "SignalRChat"); app.Map("/signalr", map => { //map.UseCors(CorsOptions.AllowAll); var hubConfiguration = new HubConfiguration { EnableDetailedErrors = true, EnableJavaScriptProxies = true, }; map.RunSignalR(hubConfiguration); }); } catch (Exception ex) { File.WriteAllText(@"C:\Logs\ex" + DateTime.UtcNow.Ticks.ToString() + ".txt", ex.Message + " " + ex.StackTrace); } } } ``` i tried enabling signalr cors but with no use and different error thrown about allow credentials to be different than true. i cant find the error or what is causing this problem if anyone can help me. ### Environment, Platform, Device Backend: .Net 4.5 webapi cordova: 9.0.0 cordova-ios: 6.1.0 device: iphonex device ios: 13.5.1 SignalR: 2.2.1.0 ## Checklist - [ ] I searched for existing GitHub issues - [x] I updated all Cordova tooling to most recent version - [x] I included all the necessary information above ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
