Android :: HttpsURLConnection Connection Problems
Sep 27, 2010
I'm a problem with a HttpsURLConnection that I can't seem to solve. Basically, I'm sending up some info to a server and if some of that data is wrong, the server sends me a 500 response code. However, it also sends a message in the response telling me which bit of data was wrong. The problem is that the message is always empty when I read it in. I think this is because a filenotfound exception always gets thrown before the stream can be read. Am I right? I tried reading the errorstream as well but this is always empty.
Here's a snippet:
CODE:........................
View 3 Replies
May 20, 2009
I have been working with the HttpsUrlConnection class and have found an interesting issue, it seems to fail on every other connection. The first request connects to the server successfully but the second one always fails. Any ideas on what i may be doing wrong.
Here is my code.
code:.................
View 3 Replies
View Related
Sep 17, 2010
I use the following code snippet to connect to a server and retrieve some data:
HttpsURLConnection con = (HttpsURLConnection)myurl.openConnection(); InputStream ins = con.getInputStream();
The code mostly works fine. If I leave the app for a few minutes, and return to it and make another request, I receive an IOException: Broken Pipe.
Once it has failed one time, it immediately works again, and will continue to do so until I leave it for a while once more.
I don't know if this is an Android specific thing, or general Java, but it doesn't happen on my desktop test version.
View 7 Replies
View Related
Aug 30, 2010
I try to establisch a HttpsURLConnection with:
CODE:.................
But I get an Exception:
CODE:......................
But I can't find out, why. The same example is everywhere across the web.
View 2 Replies
View Related
Mar 9, 2010
I am using HttpsURLConnection to post data to a web server.
Here is the function I wrote to get the result. (see the code below)
Very strangely, when the function be first called in my program it would very likely return -1; and then I re-call the function after the first call, it would always work ok.
So I wonder if there is anything I am missing in the code that when the function be firstly called, the missing party is be "initialized", in that the followed call goes OK.
Here is my code of the function:
CODE:....................
View 3 Replies
View Related
Jan 31, 2010
I'm hoping someone could help me out with intermittent connections I'm getting using code with HttpsURLConnection.
The code I'm using is below:
CODE:...............
The connection works the first time everytime when I use it to pull a json file. However, when I use the connection again to send a command, it always fails the first time. It then typically works if I send the
command quickly ( within 5 seconds), but fails if I wait a while. I don't think its a SSL issue because it connects the first time correctly, but I could be wrong here. I also tried many different
variations such as adding:
CODE:.............
However, I had no luck. Any help would be greatly appreciated.
View 2 Replies
View Related
May 15, 2010
I think I'm experiencing the same as http://groups.google.com/group/android-developers/msg/9d37d64aad0ee357
This is Android 1.5 SDK. I happen to call several times below code(which is in a method) with
the same url and it fails intermittently. When it fails, there is no exception, the stream is empty so the
readConnection fails, and getResponseCode returns -1. Global caching is disabled, setDefaultUseCaches(false);
I suppose there must be some kind of url connection object pool somewhere.
How can I workaround this?
CODE:............................
View 2 Replies
View Related
Aug 16, 2010
I try to build an https client for android and i need do get some request of an Servlet but when i use the getInputStream method the applicaion hangs.
There is no error only hanging when i call the method.
CODE:..................
This is only to check the call, but it didtn work.
the subscribe method works, when i comment out the line with the inputstream, the server show me all is correct. I can try the same with the Firefox and it works and i can see the request. i also put the keystore into the TrustManager.
View 2 Replies
View Related
Mar 12, 2010
I have some Android code that can send files to my webserver using an HttpsUrlConnection, but when it tries to send larger files I get an OutOfMemory exception when opening the OutputStream. Can anyone offer some assistance?
It looks something like this:
code:..............
This is where I try different things. The closes solution has been: httpConn.setChunkedStreamingMode(1024); In this case, I don't get the OutOfMemory immediately when opening the OutputStream, but I see the heap growing as I os.write() and it eventually runs out.
code:..............
View 7 Replies
View Related
Mar 30, 2010
I've got a problem with my application when I make a number of requests using the HttpsUrlConnection class.
My program makes the first request using the HttpsUrlConnection class to retrieve a file. It then makes a second request to the same server to retrieve a different file. What happens however is that periodically I'm getting a -1 HTTP response code on the connection.
When the failure occurs between the two requests I see the following line of trace in logcat:
D/OpenSSLSessionImpl( 699): Freeing OpenSSL session
This seems to happen fairly consistently. If I retry the second request after it has failed it generally works and I get the requested file from the server.
Note that if I don't see the OpenSSL session being freed the second request works fine the first time.
Some other information:
1) I'm not calling disconnect on the connection
2) I'm don't always read the entire file from the server after the first request
3) I always close the InputStream in the event that I get an InputStream on the first connection
How to prevent the OpenSSL session from being freed.
View 2 Replies
View Related
May 15, 2010
I'm experiencing the same as http://groups.google.com/group/android-developers/msg/9d37d64aad0ee357
This is Android 1.5 SDK. I happen to call several times below code(which is in a method) with the same url and it fails intermitently. When it fails, there is no exception, the stream is empty so the readConnection fails, and getResponseCode returns -1. Global caching is disabled, setDefaultUseCaches(false);
How can I workaround this?
CODE:.........................
View 4 Replies
View Related
Nov 24, 2010
I'm having a big issue with a static HTTPS connection method. Every second request fails and HttpsUrlConnection.getResponseCode() returns -1. So every second call works well, returning data as expected.
It's the method of a static class I'm using in different corners of my application. I would guess there is anything I don't clean up correctly when the method returns the first time and that whatever causes a problem might get destroyed through a second call of the method. But I'm having a hard time finding any clues.
I'm currently using this class to talk to hosts with invalid SSL certificates. Not going to use this in the final version of the app, but right now I need to save money. ;)
CODE:.......................
View 1 Replies
View Related
Oct 14, 2009
I'm using ThreadSafeClientConnManager to manage a pool of client connections, because my application has several threads, which are simultaneously connecting to a webserver.
Abstract sample code:
CODE:..............
Now lets say on of this threads is downloading a large file, but then the user of my application is switching to another activity/screen. Therefor the file is needless and I'd like to abort this download connection.
In ThreadSafeClientConnManager I found this method: public ClientConnectionRequest requestConnection (HttpRoute route, Object state) Returns a new ClientConnectionRequest, from which a ManagedClientConnection can be obtained or the request can be aborted.
So far I've been using:
CODE:.........
Now from what I understand, I've to use:
httpclient.getConnectionManager().requestConnection(HttpRoute route, Object state);
And that's the point where I'm stuck. I assume that for the route I can just use new HttpRoute(new HttpHost("10.0.0.1")) or whatever my server is, but what to put in for Object state?
And second, as soon as I've the ClientConnectionManager I can call getConnection(long timeout, TimeUnit tunit). But then from there, how I do I execute my HttpGet httpRequest = new HttpGet(URL_TO_FILE); as I did before with HttpResponse response = (HttpResponse) httpclient.execute(httpRequest);?
I've been gone through the documentation and tried out quite a few different things, but I wasn't able to obtain a working solution. Therefor any suggestions and/or code examples are more than welcome.
View 1 Replies
View Related
May 12, 2010
Whenever a application needs internet and connection fails, I get a message dialog
Connection failed
This application requires network access. Enable mobile network or Wi-Fi to download data.
and two buttons, Settings, Cancel.
How do I detect there is no internet connection?
How do I popup a same dialog in my application?
View 3 Replies
View Related
Oct 27, 2010
I'm coding a very basic FTP client on top of my application and I have 2 activities. The first one is the file explorer and the second one is the image viewer. Once I click on the image filename on the explorer, I want to pass the connection to the other activity to handle extra stuff. Basically, I want to keep the same org.apache.commons.net.ftp.FTPClient object (which handles the connection) alive in-between the 2 activities. I know I can't pass an object inside an intent so I don't know what my best bets are.
View 1 Replies
View Related
Jul 23, 2010
What's the technical term for being able to have voice connection and data connection simultaneously? Like AT&T was promoting heavily for a while.Apparently, the new T-Mobile Vibrant has this capability. A friend got one and was accessing the web while talking to me, double jealous now.I have benn lusting after the Verizon version, Fascinate, and wondering if there is any chance it will as well.
View 2 Replies
View Related
Sep 7, 2009
If my screen locks while I have a wifi connection, then the connection is lost when I unlock the phone.First, is this perhaps deliberate, to save power? Also, either way, when I unlock the screen and go into wifi settings, I see that the phone is trying to make a wifi connection, but it never succeeds, even though it's my home network and I'm in the same room as the router. It just states 'Obtaining address.
View 10 Replies
View Related
Sep 15, 2010
Long time reader, first time poster here. How does one know if the Epic is using the wifi connection as opposed to using the 3G connection? When wifi is connected both that and the 3G connection shows at the top. So which one is in control per se? And how can it be verified?
View 3 Replies
View Related
Jun 8, 2010
I'm wondering if it is possible to open a USB connection in my app. The idea is to plug a specific hardware into the phone USB connection and make it to "talk" with my app.
View 2 Replies
View Related
Jun 22, 2010
I'm new at programming with Android... I'm stucked at the Network topic...
Basically this is what i'm trying to do:
I wan to send some instructions using the Http protocol to a device which has a static Ip address through a private Lan Network...
So first of all I'ved Tested the Code by connecting to a wesite and everything was Ok, I could confirm the connection was made through the HttpURLConnection ResponseCode()=200 (equals to HTTP_OK) ...So my Code could access the INTERNET. But then i created a Lan Network with the Device mentionned above I couldn't have any Connection to it...neither to other devices (Pc attached to the Network)
My App gets no response...the main Screen switches to a Black untitled Screen...Is there a Permission i have to request through the MANIFEST.XML File for Lan Networks as there is a one for INTERNET?...
View 2 Replies
View Related
Jun 22, 2009
How to connect to a secured wireless network programmatically.. im able to detect and list the available networks but how do i connect to it giving a password..
View 3 Replies
View Related
Aug 22, 2009
I wrote java code that connects remote sql server. But code does not work in android.
Code is as follows:
CODE:...........
And log is follows:
CODE:..............................
View 3 Replies
View Related
Jul 16, 2010
I wanted to ask if there is a possibility to create udp connection and then change to tcp connection while the emulator is client and the server's code is java. all I found at the web is or tcp connection or udp but never a mixed between them.
View 8 Replies
View Related
Aug 7, 2009
I was wondering if it was possible to connect the lap top with the T.M G1 phone to get internet connection.
View 2 Replies
View Related
Aug 16, 2009
I am trying to connect remote ms sql server 2005 and tried something but I could'nt. Does any of you know to connect sql server? I searched and I realize that Driver must be loaded.
View 3 Replies
View Related
Apr 12, 2010
I'm fairly new to android programming and need some information for a 4th year forensics course project. Basically I am trying to create a suite of tools for live analysis of an android phone. I know how to get the information I need on the phone, but I was wondering if there was a way to communicate that information back to the PC? I want to be able to run a program from a PC, which, when the phone is docked, will allow the user to access information about the phone (ie currently running services/processes, bluetooth/wifi connections, etc). I have a bunch of methods that will run on the phone and get all the information, but I want to be able to call those methods from the PC, execute on the phone, then have the information sent back to the PC to display to the user instead of just displaying it on the phone. This is to leave as small a footprint on the phone as possible.
View 1 Replies
View Related
Apr 14, 2010
I've got my Desire to allow background sync and auto sync etc, but I was wondering if there was an app that anyone knew of that would tell me which application has been using the data connection and for how long etc? A bit like the battery stats that says which application has been using the battery but for data connection if you see what I mean.
I've seen a few apps that seem to give an overall usage figure so you can track how much data you're downloading in a month but nothing per app.I originally posted this in the HTC Desire section but I think this section is more appropriate, not sure how to move a post so have done it again. Sorry if that's a problem.
View 1 Replies
View Related
Dec 30, 2009
This is my first post as a newly registered user of the AndroidForums. I am ridiculously new at all this as I've never had a smart phone before. Anyways, I'm not sure how to connect my Motorola Droid to my MacBook. The only thing I've tried is just connecting them via USB and nothing appeared on my screen. I imagine I might need some apps or something to get the connection realized or whatever by my Mac.
View 1 Replies
View Related
Aug 30, 2010
Can it be done? If I have my PC wifi tethered to my phone, can I somehow use Gmote across that connection?
View 3 Replies
View Related
Nov 2, 2009
Is there any way to comunicate an android phone with a computer trough bluetooth? Ive made a server/client applicattion in Java using bluetooth, but i need to do the client in Android and i dont know how to start, I dont know even if is possible. I only need to send a text message.
View 2 Replies
View Related