gpt4 book ai didi

Android 本地主机拒绝连接

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:26:38 26 4
gpt4 key购买 nike

我正在与我的服务器建立一个 Http 连接,它是 apache 服务器。这是我的代码:

    BufferedReader in = null;
String data = null;

try{
HttpClient httpclient = new DefaultHttpClient();

HttpGet request = new HttpGet();
URI website = new URI("http://127.0.0.1:8888/Main.php?request=2&token=N4565345");
request.setURI(website);
HttpResponse response = httpclient.execute(request);
in = new BufferedReader(new InputStreamReader(
response.getEntity().getContent()));

}catch(Exception e){
Log.e("log_tag", "Error in http connection "+e.toString());
}

但我无法做到这一点,因为我得到了下一个错误:

Error in http connection org.apache.http.conn.HttpHostConnectException: Connection to http://10.0.0.1:8888 refused

如果有人能帮我解决这个问题,我会很高兴。谢谢

最佳答案

您调用的 url 应该由您的服务器的 ip 引用。像这样:

URI website = new URI("http://yourIp/Main.php?request=2&token=N4565345");

关于Android 本地主机拒绝连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38171616/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com