java - Android - GET Request using Https failing - not sure why -
good afternoon,
i have been making http , post requests various websites using android's httpurlconnection object few weeks , have had no problems in doing until now.
i have been required make request server using https rather http.
i presumed needed change object in use httpsurlconnection object instead in order access page.
i can verify able access page both desktop , mobile browsers. output of page text - list of items in plain text format (generated php on server).
but when try , download information using android app io exception error @ point specified below (see code block below).
the code snippet below run in different thread. manages connect , set connection parameters, upon trying open input stream fails.
unfortunately error message doesn't mean lot me. contains url of website no other information.
my thoughts either:
a) i'm missing when connecting using https - tips here great. b) website doing different other http based websites i've connected in past - not unlikely because of nature of particular website. suggestions here possibilities stopping request getting through.
yet tried: i'm planning on trying connect request alternative location using few different techniques make sure it's not i'm doing in java code.
hope clear.
thanks, matt
@override public void run() { string response = null; url url; try { url = new url(urlstr); httpsurlconnection con; try { con = (httpsurlconnection) url.openconnection(); try { con.setrequestmethod("get"); con.setreadtimeout(10000); con.setconnecttimeout(3000); con.setrequestproperty("user-agent", "mozilla/5.0"); //this fall on - after line....it raises ioexception - see below details. bufferedreader in = new bufferedreader(new inputstreamreader(con.getinputstream())); while(true) { int ch = in.read(); if(ch==-1) { break; } response = response + character.tostring((char) ch); } in.close(); } catch (protocolexception e) { } } catch (ioexception e) { //io exception raised. error message (e.getmessage()) url string...not helpful. } } catch (malformedurlexception e1) { } if(response!=null) { //do stuff response... } }
here stack trace: (i can verify file indeed exist however!)
04-24 15:16:22.854: w/system.err(12830): java.io.filenotfoundexception: https:// (ive removed website privacy purposes now) 04-24 15:16:22.854: w/system.err(12830): @ libcore.net.http.httpurlconnectionimpl.getinputstream(httpurlconnectionimpl.java:186) 04-24 15:16:22.854: w/system.err(12830): @ libcore.net.http.httpsurlconnectionimpl.getinputstream(httpsurlconnectionimpl.java:271) 04-24 15:16:22.854: w/system.err(12830): @ com.lloydm.app.mainactivity$mainlisting.run(mainactivity.java:1733) 04-24 15:16:22.854: w/system.err(12830): @ java.lang.thread.run(thread.java:856)
(stack trace reformatted)
Comments
Post a Comment