phone-as-client Socket connections time out in 3GS mode, but work fine in wifi

by Samsyn » Mon, 15 Mar 2010 09:03:13 GMT


Sponsored Links
 I wonder if this could be a Verizon thing.  What strikes me as odd is
that the UrlConnection works fine, and that must also be using tcp, so
is fundamentally the same as my subsequent Socket connection, which
fails.

The differences are:

* different server.. .MAYBE my server doesn't like the 3gs 'ip'
address of the client...
* server port 80.. MAYBE android or verizon is making a special
exemption for what looks like a web request, while applying extra
'security' for the more generic tcp connection
* maybe I need to do something to enable the socket-over-3gs (bind to
a nic?)  That UrlCconnection is smartly doing, but I am dumbly not.






--



phone-as-client Socket connections time out in 3GS mode, but work fine in wifi

by Samsyn » Thu, 18 Mar 2010 08:13:16 GMT


 adly, no joy.  I get the same behaviour trying to connect to three
different non-port-80 servers.

Recapping

* using Socket, TCP connection, originated by phone
* Have the "INTERNET" privilege

code section:

[code]

try {
mServerSocket = new Socket( );
SocketAddress adr = new InetSocketAddress( (String)
mServerAddr, mServerPort );
mServerSocket.connect(adr, 30*1000);
} catch (UnknownHostException e) {
Log.v(TAG, "Unknown host" + mServerAddr );
mLastError = "host: " + e.getMessage();
failed = true;
} catch (IOException e) {
Log.v(TAG, "Couldn't get I/O for the connection to: " +
mServerAddr );
mLastError = "IO: " + e.getMessage();
failed = true;
}
[/code]


* Emulator connects just fine,whether wifi is on or off (though
obviously the emulator uses host internet in both cases)
* Real-Phone connects fine, in WIFI mode
* Real-Phone fails, in MOBILE (3gs) mode, on verizon.

Failure is the IOException "Socket is not connected" (and appears
after the expected timeout)

--- However, THIS works on both WIFI and MOBILE connections (initiated
by real-phone on verizon)

[code]
URL myURL = new URL( "http://..." + mUrlArgs );
// Open a connection to that URL.
URLConnection ucon = myURL.openConnection();
[/code]

even to the same machine as the server that I can't connect to, but
this is a port 80 http request.

----

I'm not sure how to get deeper logging from the phone (and it only
fails on the phone) on the off chance that some logging would actually
tell me what it was complaining about.



On Mar 15, 9:26pm, Samsyn <d...@synthetic-reality.com> wrote:

--


Sponsored Links


phone-as-client Socket connections time out in 3GS mode, but work fine in wifi

by Samsyn » Fri, 19 Mar 2010 11:11:18 GMT


 K, some success, as it were.

Let the wookiie win

--

I changed my server to listen on port 80 instead and now it works fine
in both WIFI and MOBILE modes.

* server ping is now 800ms instead of 100ms
* I can not, of course, run a web server on the same machine now,
which is a small pain.

But hey, if it works for port 80, maybe it will work for some other
ports, and maybe I just was using the One Illegal Verizon Port In the
Entire World.

ooo. 950 ms ping... I can see why people say "plays better over wifi"

Well, at least I wasn't crazy, they really WERE blocking me.

- Dan


On Mar 17, 5:13pm, Samsyn <d...@synthetic-reality.com> wrote:

--



phone-as-client Socket connections time out in 3GS mode, but work fine in wifi

by Samsyn » Sat, 20 Mar 2010 10:17:45 GMT


 n Mar 18, 8:11pm, Samsyn <d...@synthetic-reality.com> wrote:
OK OK, apparently I just picked the world's worst port number (4444)
and was SO SURE that was an innocent number that I didn't even try any
others. Well, 4444 is apparently blocked by verizon/android (looks
like Oracle and others use it for admin ports)

So I will just use a nice high number that isn't on any lists I can
find.

So, my apologies for spamming the forum, but if this helps anyone
else, avoid port 4444 :-)

I hereby mark this issue resolved.


--



phone-as-client Socket connections time out in 3GS mode, but work fine in wifi

by Carlo » Thu, 22 Apr 2010 09:51:35 GMT


 i,

Any chance you have succeeded with another port than port 80 ?

We are also receiving report from user not able to reach our server
running on port 8080 from their mobile network, is there any
(recommended) list of server port that can be use ?

thanks


On Mar 20, 11:17am, Samsyn <d...@synthetic-reality.com> wrote:

--



Other Threads

1. why can't catch the SocketTimeoutException

Key code below:

                    try {
                        Xml.parse(operation.outBody,
Xml.Encoding.UTF_8, parser); //  Line 89
                    } catch (SocketException e) {
                        Log.e(TAG, "getAlbumPhotos: " + e);
                        ++syncResult.stats.numIoExceptions;
                        e.printStackTrace();
                        return RESULT_ERROR;
                    } catch (SocketTimeoutException e) {  // why
SocketTimeoutException can't be catched there?????
                        Log.e(TAG, "getAlbumPhots: " + e);
                        ++syncResult.stats.numIoExceptions;
                        e.printStackTrace();
                        return RESULT_ERROR;
                   }



01:00:50 E/AndroidRuntime(935): FATAL EXCEPTION: SyncAdapterThread-1

java.lang.AssertionError: java.net.SocketTimeoutException

        at android.util.Xml.parse(Xml.java:89)

        at com.cooliris.picasa.PicasaApi.getAlbumPhotos(PicasaApi.java:293)

        at 
com.cooliris.picasa.PicasaContentProvider.syncAlbumPhotos(PicasaContentProvider.java:400)

        at 
com.cooliris.picasa.PicasaContentProvider.syncUserPhotos(PicasaContentProvider.java:362)

        at 
com.cooliris.picasa.PicasaContentProvider.syncUsersAndAlbums(PicasaContentProvider.java:185)

        at 
com.cooliris.picasa.PicasaService.performSyncImpl(PicasaService.java:177)

        at com.cooliris.picasa.PicasaService.performSync(PicasaService.java:113)

        at 
com.cooliris.picasa.PicasaSyncAdapter.onPerformSync(PicasaSyncAdapter.java:74)

        at 
android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:164)

Caused by: java.net.SocketTimeoutException

        at 
org.apache.harmony.luni.net.PlainSocketImpl.read(PlainSocketImpl.java:461)

        at 
org.apache.harmony.luni.net.SocketInputStream.read(SocketInputStream.java:85)

        at 
org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:103)

        at 
org.apache.http.impl.io.AbstractSessionInputBuffer.read(AbstractSessionInputBuffer.java:134)

        at 
org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:161)

        at 
org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:175)

        at 
org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:178)

        at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:225)

        at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:178)

        at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:174)

        at java.io.FilterInputStream.read(FilterInputStream.java:133)

        at 
org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:516)

        at 
org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:479)

        at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:318)

        at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:275)

        at android.util.Xml.parse(Xml.java:87)

        ... 8 more

-- 

2. Set wallpaper from webview

Hi, I have created 3D rendered images which I have added to an app
using Webview and I would like the option to allow the user to set
each picture as wallpaper.
I have searched high and low for this info but can't find anything.
Any information would be great. Thanks.

-- 

3. Multiple content providers to sync...

4. [WTS] titipan temen Samsung Galaxy Spica hitam 2nd

5. Benchmark Test: HTC Pyramid vs. LG Optimus 2X

6. xperia play cdma/gsm

7. Swype Bahasa Indonesia for Motorola Defy WVGA854 (Moded by keaton)