java.net.ConnectException: 无法连接到/127.0.0.1:9080 领域对象服务器 [英] java.net.ConnectException: Failed to connect to /127.0.0.1:9080 realm Object server

查看:81
本文介绍了java.net.ConnectException: 无法连接到/127.0.0.1:9080 领域对象服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在看到网站中的文档后,我刚刚安装了领域对象服务器.我创建了一个登录页面 (android),并根据网站使用了同步用户设置.但是我在创建时的 asynctask 显示了上述错误.这是我的代码:

I just installed realm object server after seeing the documentation in the website.I created a login page (android) and i used syncronised user settings as per the website. but my asynctask on create shows the above error. Here is my code :

public class RealAsyncTask extends AsyncTask<String, Void, String> {

Realm realm;
String url = "http://127.0.0.1:9080";
long schemaVersion = 001;

@Override
protected String doInBackground(String... strings) {
    try {
        SyncCredentials syncCredentials = SyncCredentials.usernamePassword("realm-admin", "", true);
        SyncUser user = SyncUser.login(syncCredentials, serverUrl());
        SyncConfiguration config = new SyncConfiguration.Builder(user, realmUrl())
                .schemaVersion(schemaVersion)
                .build();
        realm.setDefaultConfiguration(config);
    }
    catch (Exception e){
        e.getCause();
    }
    return null;
}

private String realmUrl() {
    return url;
}

private String serverUrl() {
    return url;
}
}

我正在我的手机上部署我的应用程序,在调试时我收到了上述错误消息.先谢谢您的帮助.

I am deploying my application in my mobile and while debugging i got the above error message. Thanks in advance for the help.

推荐答案

将服务器和手机连接在同一网络上或将服务器托管在 Web 服务器中.

Connect the server and mobile on the same network or host the server in web server.

使用服务器系统的 IP 地址 而不是 127.0.0.1.

Use server system's IP Address instead of 127.0.0.1.

如果您使用的是 Emulator,请使用 IP 10.0.2.2.

Use IP 10.0.2.2 if you are using an Emulator.

每个系统本身都是一个本地主机,因此当您调用 127.0.0.1 时,系统会调用自身.

这篇关于java.net.ConnectException: 无法连接到/127.0.0.1:9080 领域对象服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆