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();
}
有沒有人收到這個問題,或者可能有一些想法?
問候 恭
謝謝:) ..問題解決了...好吧這真的很尷尬..但我忘了在我的設備上啓動wifi .. – 2011-03-02 11:24:24