繁体   English   中英

Android:webview:获取错误代码 -6 net::ERR_CONNECTION_REFUSED

[英]Android : webview : getting error code -6 net::ERR_CONNECTION_REFUSED

我在 android webview 上不断收到错误代码 -6 和描述 net::ERR_CONNECTION_REFUSED

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final WebView webview =(WebView) this.findViewById(R.id.webView);

    WebSettings webSettings = webview.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webview.setWebViewClient(new MyWebViewClient());//I only implemented onReceivedError to display the errors in logcat

    webview.loadUrl("http://mydomainexample.com");// it loads http://google.com but throws error code = -6 for my doamin which works fine in any navigator

}

虽然完全相同的 url(例如http://aaaaaaaaa.com )在任何导航器中都能很好地工作,但 webviews 与导航器的连接是否不同? 什么可能导致这个问题?

可能是由于网站的 cookie 请求(请参阅Android Webview 错误代码 -6 ),但请发布您的代码。 https://github.com/ionic-team/capacitor/issues/1848上也有帖子

问题是加载的网页有一个 js 文件,该文件异步地向服务器上阻止的端口发出请求。 我已经尝试删除该请求并且它起作用了

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM