Thanks for the answer, but I found out why I saw the strange behaviour. The code was invoked by a Service that hadn't acquired a WakeLock. Acquiring a WakeLock (PowerManager.PARTIAL_WAKE_LOCK) solved the problem with setConnectTimeout behaving in a strange way.
One thing that still is odd is that the first connection attempt always get a timeout. I then try to a connect again, and that one succeeds. Does anyone know what might cause this? On 11 Dec, 17:44, Jeffrey Blattman <[email protected]> wrote: > you can try doing the same thing w/ the httpclient classes. i know that > doesn't answer your question but it's something else to try. > > On 12/11/09 3:53 AM, Kaj Bjurman wrote: > > > > > > > Hi, > > > I have code that is reading data from a website, the website that I'm > > reading data from is at times a bit slows, so I want to use > > setConnectTimeout on the URLconnection that I'm using. > > > The problem is that it looks like the value is ignored, or that it > > doesn't work. I have set the setConnectTimeout to 30 seconds (i.e. > > 30000 as value since the javadoc says that the argument is in ms). > > > I then call connect, and I have through my logs seen that the code can > > get blocked in the connect call for several hours (in Android 1.6, > > don't know about the other versions). > > > Has anyone else seen this problem? What to do about it? I don't see > > how I would create a workaround since I don't have anything that I can > > invoke close on (I would create a separate thread that invoked close > > on the stream/socket after a certain time if the problem was related > > to slow reading) > > > Thanks > > Kaj > > -- > > qr-gmail.png > < 1KVisaHämta -- 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

