Just to let you know I also had problems with URLConnection when using https. Eeentually I had to switch to http client wich works fine.
Regards, Siarhei On Jan 29, 8:32 pm, Kai <kai.umez...@hotmail.jcom> wrote: > Thank you very much for those suggestions, I will definitely take a > look at them. > > Have your worked at all with httpS though? and if so, are there any > differences in the implementation. As mentioned in the original post, > I have no problem getting HTTP to work, it is only when I switch to > HTTPS that I start having problems. > > On Jan 27, 2:46 pm, WoodManEXP <woodman...@gmail.com> wrote: > > > > > Hello, > > > I have done a lot of work with the Android communicating via http, Get > > and Post, with servers. Most of it seems to work pretty much the same > > as the org.apache.http.* libraries on other platforms (which is in > > itself pretty neat!). > > > Couple of things that might be helpful > > > - Do the http work off the UI thread because of the way server > > communication delays and times-out and such. Otherwise the Android app > > manager will freak-out and the ANR dialog will appear (App not > > responding). > > > - This may be wrong but our apps tend to create and dispose of > > DefaultHttpClients often, rather then keeping them around for re-use. > > We experienced problems trying to reuse object like these (kind of > > like to describe with the java.io.IOExceptions) > > > On Jan 27, 11:30 am,Kai<kai.umez...@hotmail.com> wrote: > > > > Hi all, > > > > I'm in the middle of developing my first android application and have > > > finally hit a significant roadblock that I can't seem to figure a way > > > around. > > > > The application involves HTTPS posting from an activity within the app > > > to my test server. While I've worked around accepting the self-signed > > > certificate, the behavior of the post and response has been > > > problematic and non-standard and so I'm wondering if this issue is > > > android related and what some possible solutions might be. > > > > Essentially this transaction is completed on a click. On the click I > > > create and connect a HttpsURLConnection to the server, setting > > > DoOutput and DoInput to true. I get the connection output stream and > > > wrap it in a BufferedOutputStream. I write the transaction to the > > > BuffStream, flush and close it. > > > > Then I handle the response. If the response is HTTP_OK, I get and wrap > > > the connection input stream in a BufferedInputStream. I then take the > > > input and put it into a byte array to be handled by the app and close > > > the input stream. > > > > Now this all seems straight forward but when tested doesn't work > > > properly. From the activity, the process is always successful on the > > > first try, but then from the same activity if I wait a few seconds > > > then click again, the same process will fail claiming a > > > java.io.IOException(stream is closed), and then if I wait a few more > > > seconds and try again it will work and this pattern continues on. To > > > make things even more confusing, if I execute all of the clicks in > > > rapid succession they will all work. It only complains if I wait in > > > between transactions. I've come to think that the problem has > > > something to do with Android HTTPS as when I try just a simple HTTP > > > post, everything works fine. I also don't think it has anything to do > > > with my custom certificate accepting as when I removed that and tried > > > HTTPS posting to a trusted well known certificate, the problem still > > > occurred. > > > > I'm leaning towards the thought that this has something to do with > > > setting up and tearing down HTTPS connections in android, but as I do > > > this all in an onClick event I'm not sure why I'm experiencing > > > problems half the time. I'm also inclined to think its the inputStream > > > that is having issues as the server seems to recieve the transactions. > > > > Anyone with any ideas as to what could be going wrong, or anyone who > > > can outline how they went about setting up an HTTPS post on click > > > would be greatly appreciated! > > > > Thanks so much for your time and consideration. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en