Problem with connection Android

Hello,

I have problem with connection on my server. Afer I want to connect, I get exception:

java.net.ConnectException: HttpClientChannel : an error occurred while attempting to connect to the server

here is my code:

public void serverLogin2() throws Exception{
	try{
		BinMessage bm = new BinMessage();
		URL url = new  URL("http://192.168.1.206:25334/BIN");
		HttpClientChannel ch = new HttpClientChannel(url);
		ch.setTimeout(20000);
		
		IsvcLogin svcLogin = new svcLogin_Proxy(bm, ch);
		
		String str = svcLogin.GetMyString(); //>> I can not get my string from the server
		}
    } catch (Exception e) {
        throw e;	
	}finally{
	}
}

If i copy “http://192.168.1.206:25334/BIN” into my browser’s url, I get all the server’s content. I have turn off my windows firewall, too.

I wasn’t found my mistake, can anybody help me please ?

Hnak you,

B.

I forgot,

in my manifest I had permissions:

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

B.

AFAIK, android forbids networks calls in main thread so they should be performed asynchronously.
look at HTTP Chat for Android sample. it contains similar login call:

lURI = new URI("http://10.0.2.2:8099/bin");
aChatService = new HTTPChatService_AsyncProxy(lURI);
...
try {aChatService.beginLogin(lUserLogin, true, new AsyncRequest.IAsyncRequestCallback(){
		@Override
		public void completed(AsyncRequest arg0) {...}
		@Override
		public void failed(AsyncRequest arg0, Exception arg1) {...}		
	});
} catch(Exception e) {...}
1 Like