0

我正在编写一个 android 客户端,它通过 web 服务使用来自服务的一些数据。在模拟器上运行应用程序时,一切都很好。现在我想在真实设备上测试我的应用程序。服务器目前正在本地运行。登录失败。

03-02 10:27:31.066: WARN/System.err(6301): java.net.SocketException: The operation timed out
03-02 10:27:31.077: WARN/System.err(6301):     at org.apache.harmony.luni.platform.OSNetworkSystem.connectStreamWithTimeoutSocketImpl(Native Method)
03-02 10:27:31.077: WARN/System.err(6301):     at org.apache.harmony.luni.platform.OSNetworkSystem.connect(OSNetworkSystem.java:115)
03-02 10:27:31.077: WARN/System.err(6301):     at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:244)
03-02 10:27:31.077: WARN/System.err(6301):     at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:533)
03-02 10:27:31.077: WARN/System.err(6301):     at java.net.Socket.connect(Socket.java:1055)
03-02 10:27:31.077: WARN/System.err(6301):     at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
03-02 10:27:31.077: WARN/System.err(6301):     at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:143)
03-02 10:27:31.077: WARN/System.err(6301):     at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
03-02 10:27:31.087: WARN/System.err(6301):     at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
03-02 10:27:31.087: WARN/System.err(6301):     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:348)
03-02 10:27:31.087: WARN/System.err(6301):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
03-02 10:27:31.087: WARN/System.err(6301):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:653)
03-02 10:27:31.087: WARN/System.err(6301):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:627)
03-02 10:27:31.087: WARN/System.err(6301):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:616)
03-02 10:27:31.087: WARN/System.err(6301):     at com.mobilesociato.activities.Login.onLogin(Login.java:121)
03-02 10:27:31.087: WARN/System.err(6301):     at java.lang.reflect.Method.invokeNative(Native Method)
03-02 10:27:31.087: WARN/System.err(6301):     at java.lang.reflect.Method.invoke(Method.java:521)
03-02 10:27:31.087: WARN/System.err(6301):     at android.view.View$1.onClick(View.java:2067)
03-02 10:27:31.087: WARN/System.err(6301):     at android.view.View.performClick(View.java:2408)
03-02 10:27:31.087: WARN/System.err(6301):     at android.view.View$PerformClick.run(View.java:8817)
03-02 10:27:31.087: WARN/System.err(6301):     at android.os.Handler.handleCallback(Handler.java:587)
03-02 10:27:31.097: WARN/System.err(6301):     at android.os.Handler.dispatchMessage(Handler.java:92)
03-02 10:27:31.097: WARN/System.err(6301):     at android.os.Looper.loop(Looper.java:144)
03-02 10:27:31.097: WARN/System.err(6301):     at android.app.ActivityThread.main(ActivityThread.java:4937)
03-02 10:27:31.097: WARN/System.err(6301):     at java.lang.reflect.Method.invokeNative(Native Method)
03-02 10:27:31.097: WARN/System.err(6301):     at java.lang.reflect.Method.invoke(Method.java:521)
03-02 10:27:31.097: WARN/System.err(6301):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-02 10:27:31.097: WARN/System.err(6301):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-02 10:27:31.097: WARN/System.err(6301):     at dalvik.system.NativeStart.main(Native Method)

这是我的登录信息:

// Anfrage Login
    HttpPost requestLogin = new HttpPost(PathContainer.loginURL);
    HttpResponse response = null;

    // Parameter fuer Post Anfrage an die URL spring_security_check
    // Name und Password werden uebergeben
    // Login wie in Browser
    List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("j_username", username));
    params.add(new BasicNameValuePair("j_password", password));

    // LOGIN
    // Fuegt Parameter (Name und Password) der URL hinzu
    try {
        requestLogin
                .setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    HttpHost proxy = new HttpHost("192.168.1.116", 8080);
    c.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);

    try {
        response = c.execute(requestLogin);
    } catch (ClientProtocolException e1) {
        e1.printStackTrace();
    } catch (IOException e1) {
        e1.printStackTrace();
    }

以前有没有人遇到过这个问题或者可能有一些想法?

问候克里斯汀

4

1 回答 1

0

您能否确认您的设备网络无线电已打开并且可以通过 Wi-Fi 或 GS​​M 无线电访问您的服务器?

于 2011-03-02T10:35:18.797 回答