2011-03-02 37 views
0

我正在写一个android客户端,它通过webservices使用服务中的一些数据。在模拟器上运行应用程序时,一切都很好。现在我想在真实设备上测试我的应用程序。服务器此刻正在运行本地。登录失败。Android应用程序 - 套接字例外:操作超时

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(); 
    } 

有没有人收到这个问题,或者可能有一些想法?

问候 恭

回答

0

能否请您确认您的设备的网络电台上,并具有可达性通过Wi-Fi或GSM无线你的服务器?

+1

谢谢:) ..问题解决了...好吧这真的很尴尬..但我忘了在我的设备上启动wifi .. – 2011-03-02 11:24:24