Sadly, 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:26 pm, Samsyn <[email protected]> wrote:
> Thanks for the suggestion Michael, I'll give that a try.
>
> I went through some abortive experiments with
> requestHostForConnection() (man that turned out to be a major pain)
> and that bore no fruit (so I was happy to tear it out).
>
> There is also a connect through proxy option which might bear fruit.
> But maybe I should also look at the firewall logs on that server to
> see what it says (I am of the opinion that it will accept connections
> from anyone, but opinion is often not fact)
>
> - Dan
>
> On Mar 15, 10:37 am, Michael MacDonald <[email protected]>
> wrote:
>
>
>
> > On 03/14/10 21:03, Samsyn wrote:
>
> > > 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.
>
> > > On Mar 12, 11:42 pm, Samsyn <[email protected]> wrote:
>
> > >> I'm sorry for what must be a really dumb question... my app is a
> > >> client, the server is a linux box in a colo.  I use android Sockets to
> > >> connect to the server.  It works great.
>
> > >> that is, it works great when the phone is on wifi.
>
> > >> But when the phone is on 3G, the socket connection times out.
>
> > >> ---
>
> > >> The ONLY permission my app is asking for is 'INTERNET' (which is
> > >> apparently enough for it to work on wifi).
>
> > >> What am I missing?
>
> > >> My app also uses a URLConnection to discover the server address (by
> > >> asking a second server, whose address is well known).  That works both
> > >> in wifi and 3G, but is a port 80 http request, so probably is
> > >> considered pretty inoffensive.  Still, it makes me feel like this is
> > >> not some subtle radio startup issue.
>
> > >> ---
>
> > >> It smells like a permission issue, but reading through the
> > >> permissions, I don't see any that scream out 'enable sockets on 3G'
>
> > >> Note, the phone is always a client.  this is not about incoming
> > >> connections.  This is an outbound TCP connection from the phone to a
> > >> remote server (which is not a phone).
>
> > >> It also works in the emulator, even when you tell the emulator to
> > >> disable wifi, but I'm not sure that proves anything.
>
> > >> Is there another permission I am missing?
>
> > >> - Dan
>
> > I would suspect that there is no route from the phone to your remote
> > server.  This could be Verizon shenanigans, but I don't think so because
> > other non-port-80 apps seem to connect happily to various hosts.  This
> > suggests a problem on your server (specifically Internet-to-server)
> > side.  Try running the app on an emulator through a different ISP from
> > one the one hosting your server: does that work?- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to