简体   繁体   中英

Android : webview : getting error code -6 net::ERR_CONNECTION_REFUSED

I keep getting errorcode -6 and description net::ERR_CONNECTION_REFUSED on android webview in

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

}

while the exact same url (example http://aaaaaaaaa.com ) works well in any navigator, do webviews make connections differently from navigators? What could be causing this issue?

Maybe due to cookie request by the website (see Android Webview error code -6 ) but please post your code. There is also a posting on https://github.com/ionic-team/capacitor/issues/1848

The issue was that the loaded webpage had a js file that, asynchronously, made a request to a port which was blocked on the server. I've tried removing that request and it worked

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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