Socket cannot connect to server via mobile internet because I use hostname instead of IP but works in i.e. Eclipse and via WIFI
<p>I have problem with connection between Android phone and server on Raspberry Pi via mobile internet. I created simple server on RPi and Client on android. I also instaled Weaved software to DNS problem. When I use simple client in another PC in i.e Eclipse I can connect to server using i.e:</p>

<pre><code>client = new Socket("proxy.11.xxx.net", 54812)
</code></pre>

<p>The same is on android when I use WIFI. Problem starts when I switch off WIFI. Socket dosn't connect to server. I set permission: </p>

<pre><code>&lt;uses-permission android:name="android.permission.INTERNET" /&gt; 
&lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
</code></pre>

<p>There is no any exceptions. Socket created successful but doesn't connect to server. </p>

<p>I.E I put</p>

<pre><code>proxy.11.xxx.net:54812
</code></pre>

<p>to web browser and enter, there is connection to server.
Ofcourse it works when I am in local network via WIFI and put straight IP number of RPi but it isn't what I mean. I want to be able connect via Internet from android. Why I can connect the same address from PC and on android not?</p>

<p>Anyone can help/give advice?</p>

<p><strong>EDIT:</strong></p>

<p>When I use: <code>new Socket (proxy.11.xxx.net,54812)</code> there is no Exception. Socket is created ok: <a href="http://imgur.com/pTHXaAE" rel="nofollow">http://imgur.com/pTHXaAE</a></p>

<p>When I use <code>new Socket(http://proxy.11.xxx.net,54812)</code>:</p>

<pre><code>java.net.UnknownHostException: Unable to resolve host "http://proxy11.yoics.net": No address associated with hostname
06-10 22:03:46.576 29922-29944/com.mmc.mateusz.rpilight W/System.err:     at java.net.InetAddress.lookupHostByName(InetAddress.java:457)
06-10 22:03:46.576 29922-29944/com.mmc.mateusz.rpilight W/System.err:     at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
06-10 22:03:46.576 29922-29944/com.mmc.mateusz.rpilight W/System.err:     at java.net.InetAddress.getAllByName(InetAddress.java:215)
06-10 22:03:46.576 29922-29944/com.mmc.mateusz.rpilight W/System.err:     at java.net.Socket.tryAllAddresses(Socket.java:109)
06-10 22:03:46.576 29922-29944/com.mmc.mateusz.rpilight W/System.err:     at java.net.Socket.&lt;init&gt;(Socket.java:178)
06-10 22:03:46.576 29922-29944/com.mmc.mateusz.rpilight W/System.err:     at java.net.Socket.&lt;init&gt;(Socket.java:150)
06-10 22:03:46.576 29922-29944/com.mmc.mateusz.rpilight W/System.err:     at com.mmc.mateusz.rpilight.Client.openSocket(Client.java:50)
06-10 22:03:46.576 29922-29944/com.mmc.mateusz.rpilight W/System.err:     at com.mmc.mateusz.rpilight.Client.doInBackground(Client.java:76)
06-10 22:03:46.576 29922-29944/com.mmc.mateusz.rpilight W/System.err:     at com.mmc.mateusz.rpilight.Client.doInBackground(Client.java:30)
06-10 22:03:46.576 29922-29944/com.mmc.mateusz.rpilight W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:292)
06-10 22:03:46.576 29922-29944/com.mmc.mateusz.rpilight W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
06-10 22:03:46.576 29922-29944/com.mmc.mateusz.rpilight W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
06-10 22:03:46.576 29922-29944/com.mmc.mateusz.rpilight W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
06-10 22:03:46.576 29922-29944/com.mmc.mateusz.rpilight W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
06-10 22:03:46.576 29922-29944/com.mmc.mateusz.rpilight W/System.err:     at java.lang.Thread.run(Thread.java:818)
06-10 22:03:46.577 29922-29944/com.mmc.mateusz.rpilight W/System.err: Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)
06-10 22:03:46.577 29922-29944/com.mmc.mateusz.rpilight W/System.err:     at libcore.io.Posix.android_getaddrinfo(Native Method)
06-10 22:03:46.577 29922-29944/com.mmc.mateusz.rpilight W/System.err:     at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:55)
06-10 22:03:46.577 29922-29944/com.mmc.mateusz.rpilight W/System.err:     at java.net.InetAddress.lookupHostByName(InetAddress.java:438) 
</code></pre>