我正在使用客户端服务器应用程序。客户端是 Ubuntu 平台中的 Android 设备。我的服务器是 IIS,即 MS Visual Studio 2010。两个系统(Ubuntu-Android Aap 正在开发的地方,Window7-服务器所在的地方)都通过 WI-FI 连接。我遇到了一个例外
03-29 09:56:54.141: I/System.out(576): Place order click
03-29 09:56:54.262: I/System.out(576): address = http://192.168.1.3/RestaurantPOSNew/ProcessOrder.aspx?order_id=3&table_no=11&order_items=%5B%7B%22OrderID%22%3A3%2C%22isAdd%22%3Atrue%2C%22itemId%22%3A2%2C%22quantity%22%3A4%7D%2C%7B%22OrderID%22%3A0%2C%22isAdd%22%3Afalse%2C%22itemId%22%3A0%2C%22quantity%22%3A0%7D%5D
03-29 09:56:59.382: I/dalvikvm(576): threadid=4: reacting to signal 3
03-29 09:56:59.412: I/dalvikvm(576): Wrote stack traces to '/data/anr/traces.txt'
03-29 09:57:15.271: W/System.err(576): org.apache.http.conn.HttpHostConnectException: Connection to http://192.168.1.3 refused
03-29 09:57:15.303: W/System.err(576): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:178)
03-29 09:57:15.303: W/System.err(576): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
03-29 09:57:15.303: W/System.err(576): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
03-29 09:57:15.303: W/System.err(576): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
03-29 09:57:15.303: W/System.err(576): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
03-29 09:57:15.303: W/System.err(576): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
03-29 09:57:15.303: W/System.err(576): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
03-29 09:57:15.312: W/System.err(576): at com.sst.restaurant.RestaurantHome.sendJSONOrderToServer(RestaurantHome.java:1480)
03-29 09:57:15.322: W/System.err(576): at com.sst.restaurant.RestaurantHome$8.onClick(RestaurantHome.java:1172)
03-29 09:57:15.322: W/System.err(576): at android.view.View.performClick(View.java:3110)
03-29 09:57:15.322: W/System.err(576): at android.view.View$PerformClick.run(View.java:11928)
03-29 09:57:15.322: W/System.err(576): at android.os.Handler.handleCallback(Handler.java:587)
03-29 09:57:15.322: W/System.err(576): at android.os.Handler.dispatchMessage(Handler.java:92)
03-29 09:57:15.322: W/System.err(576): at android.os.Looper.loop(Looper.java:132)
03-29 09:57:15.322: W/System.err(576): at android.app.ActivityThread.main(ActivityThread.java:4025)
03-29 09:57:15.322: W/System.err(576): at java.lang.reflect.Method.invokeNative(Native Method)
03-29 09:57:15.322: W/System.err(576): at java.lang.reflect.Method.invoke(Method.java:491)
03-29 09:57:15.322: W/System.err(576): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
03-29 09:57:15.322: W/System.err(576): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
03-29 09:57:15.332: W/System.err(576): at dalvik.system.NativeStart.main(Native Method)
03-29 09:57:15.342: W/System.err(576): Caused by: java.net.ConnectException: /192.168.1.3:80 - Connection refused
03-29 09:57:15.342: W/System.err(576): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:211)
03-29 09:57:15.352: W/System.err(576): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:431)
03-29 09:57:15.352: W/System.err(576): at java.net.Socket.connect(Socket.java:901)
03-29 09:57:15.352: W/System.err(576): at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
03-29 09:57:15.352: W/System.err(576): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:143)
03-29 09:57:15.362: W/System.err(576): ... 19 more
03-29 09:57:15.393: I/System.out(576): inside handler
03-29 09:57:15.691: D/dalvikvm(576): GC_CONCURRENT freed 844K, 11% free 10643K/11847K, paused 8ms+65ms
我在清单文件中声明了互联网许可。我在终端中通过 ping 命令检查了两个系统都在同一个网络中。