如何对本地Windows UWP(Cordova)网络问题进行故障排除



我有一个使用离子/cordova构建的Windows 10 UWP应用程序,因此我的HTTP请求源自嵌入式WebView。

我可以在家中运行我的应用程序,也可以在通过单元格连接的平板电脑上运行我的应用程序,并且HTTP请求所有工作。但是,当我在任何办公机器(工作机)上运行此操作时,除了对本地主机以外的请求似乎被阻止了。我最初认为这是网络,但是使用Wireshark,如果我只是在机器浏览器中运行它们,我可以看到该请求,但是如果我从应用程序运行相同的情况下,我看不到它们。

如果我通过桌面浏览器(使用离子服务)运行该应用程序,则也有效。它似乎只是在UWP容器中运行时。

由于请求没有出现在Wireshark中,因此我不知道如何诊断在哪里被阻止。

我如何诊断(我假设本地TCP/IP堆栈?)

更新1

有关最小应用的更多信息

我创建了一个新的离子3应用程序,直接从模板中,我的config.xml看起来像

    <?xml version='1.0' encoding='utf-8'?>
    <widget id="io.ionic.starter" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
        <name>MyApp</name>
        <description>An awesome Ionic/Cordova app.</description>
        <author email="hi@ionicframework" href="http://ionicframework.com/">Ionic Framework Team</author>
        <content src="index.html" />
        <access origin="*" />
        <allow-intent href="http://*/*" />
        <allow-intent href="https://*/*" />
        <allow-intent href="tel:*" />
        <allow-intent href="sms:*" />
        <allow-intent href="mailto:*" />
        <allow-intent href="geo:*" />
        <allow-navigation href="*" />
        <feature name="http://api.phonegap.com/1.0/network" />
        <access origin="*" />
        <preference name="webviewbounce" value="false" />
        <preference name="UIWebViewBounce" value="false" />
        <preference name="DisallowOverscroll" value="true" />
        <preference name="android-minSdkVersion" value="16" />
        <preference name="BackupWebStorage" value="none" />
        <preference name="SplashMaintainAspectRatio" value="true" />
        <preference name="FadeSplashScreenDuration" value="300" />
        <preference name="SplashShowOnlyFirstTime" value="false" />
        <preference name="SplashScreen" value="screen" />
        <preference name="SplashScreenDelay" value="3000" />
        <preference name="windows-target-version" value="10.0" />
        <platform name="android">
            ...
        <platform name="ios">
           ...
        </platform>
        <engine name="windows" spec="^5.0.0" />
        <plugin name="cordova-plugin-console" spec="^1.0.5" />
        <plugin name="cordova-plugin-device" spec="^1.1.4" />
        <plugin name="cordova-plugin-splashscreen" spec="^4.0.3" />
        <plugin name="cordova-plugin-statusbar" spec="^2.2.2" />
        <plugin name="cordova-plugin-whitelist" spec="^1.3.1" />
        <plugin name="ionic-plugin-keyboard" spec="^2.2.1" />
        <plugin name="cordova-plugin-wkwebview-engine" spec="^1.1.3" />
    </widget>

当我构建到窗口包时,appxmanifest.xml包括以下...

 <Capabilities>
   <Capability Name="internetClient" />
 </Capabilities>

测试服务应启用CORS,我可以通过单元格连接到它,除了我们的Office网络外,我尝试过的任何其他网络,因为我们不知道它在哪里被阻止。我在Wireshark中看不到任何东西。如果我通过离子服务运行相同的应用程序(因此在桌面浏览器中运行),那么我就没有问题了。如果我在家安装Windows版本,我可以连接。如果我将其安装在平板电脑(例如表面)上,则如果Serface在Office WiFi上,则不会连接,但是如果我将表面绑在手机上,则可以连接。

如果我们给出表面固定的IP 它似乎也可以工作。我不知道为什么固定的IP有所作为。

实际的测试应用程序代码如下(唯一的区别是Office测试服务器的URL)...

    export class HomePage {
      public result : any;
      public url : string;
      constructor(public navCtrl: NavController, private http: Http) {
        this.url='http://mytesturl';           
      }
      public onClick() : void {  
          this.http.get(this.url).subscribe(res => {
           this.result = res.statusText;
           console.log(res);
         }, (error : Response) => {
           let json = error.json();
           this.result = `failed  ${error.statusText}`;
           console.log(error);
         });                    
      }
    }

我们遇到了相同的问题,并通过将功能" PrivateNetworkClientserver"添加到应用程序中来修复。也许这也是您的问题?

最新更新