Android :: HttpsUrlConnection And OpenSSL Freeing Session
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
Oct 18, 2010
I have an app with 2 Activities and an IntentService all which need to access the same SQLite Database table. What's an appropriate pattern to use?
Should I create a ContentProvider that manages access to the database, ie opening/closing, querying, updating etc. And have the 3 clients all access the DB via the ContentProvider?
Or is it OK for each client to access the DB directly? This is the approach I have now and it seems to be working, but I need to close my cursor and the DB after executing every statement or I start generating stacktraces in the log about unclosed DB resources. But closing the DB after each statement seems wasteful and I suspect that this approach will always be susceptible to the stacktraces because there is always the potential for collisions between either of the Activities and the IntentService.
I haven't been able to find any good resources that show DB usage in full. It always snippets that miss out the *obvious* piece such as when should the resources be closed etc.
View 6 Replies
View Related
Jun 1, 2010
I want to use DTLS (on OpenSSL) using JNI on Android 2.1/2.2. Can someone help me get started (tutorials, howto, pointers etc) with building OpenSSL for Android (2.1/2.2) using the Android NDK?
View 1 Replies
View Related
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
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
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
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
Aug 25, 2010
This is a follow up question of http://stackoverflow.com/questions/3550593/sending-html-commands-over-httpclient-android , I have successfully Posted to the server and received 200 code but when I attempt to move to another page it does not recognize that I have logged in. I am wondering if it is a session issue or if i need to follow the redirect after the POST. How would I go about following a redirect?
View 1 Replies
View Related
Nov 19, 2010
I make an app with some activities.
The first is the login.
If I login correctly, I pass to the second activity, and I want download a stream (like twitter), but I cannot keep the session.
I saved user & pass in sharedpreferences, how can i keep the session through all activities?
View 1 Replies
View Related
Apr 9, 2010
I have an app that requires user to register. I've got the app conected to PHP in my server to do the logic of register/login and so, this is not problem at all.
But, I want to keep a session of the user in local, so the user doesn't have to login again every time he runs the app.
So, I want something like this:
First time user, he opens the app, register and login. Do some stuff with the app and closes it. Open the app again, the user is recognized so he doesn't need to login again.
I only need to store an ID and a Username (both fetched from the DB in the login php method). What's the best way to do this?
I've thought about doing a custom preference, store the data in files or even a local DB (sqlite).
View 1 Replies
View Related
Mar 15, 2010
The user must login through the WebView. Of course, the session is for that WebView.But, what if I need to make REST API calls during my Android application?Those REST API calls need the session to be authenticated , otherwise those will not work. Is there any way I can attach the cookies of WebView into everything I do in Android?
View 1 Replies
View Related
Jan 13, 2010
Can any one tell me how can we clear browse session history.We have api called Browser.ClearHistory(),this will delete entire records but i want to delete history of browsing session.
View 2 Replies
View Related
Oct 28, 2010
I'm trying to avoid that when a user has connected to Facebook from my webview, the next time he do it, doesn't need to put the email and password. but doesn't work. That cookie I suppose that is not valid because the user has to put his username and his password again and after login, I get a different cookie that the one I had stored. What I'm doing wrong? Is there another way to accomplish that?
View 3 Replies
View Related
Feb 26, 2009
Ok I am at the end of my rope. I am doing some image processing. I have a large image file which I open and create a smaller bitmap from. At the end of processing I call recycle on everything. I null everything. I run GC manually.
I then try edit another image and I get an out of VM memory error. Bitmap exceeds etc etc.
I am looking at the heap and the secone edit doesn't seem to cause it to increase at all.
What else can I do. Surely google cannot possibly be suggesting that we can open one large bitmap per session and thats it?
View 16 Replies
View Related
Jun 23, 2010
I am using Ksoap2-Android for consuming the WCF Services.
For the dotnet client we keep the allowCookies="true" in our binding configuration and it sends the same sessionid and keeps my sessions intact in my WCF services (My services are
interdependent and use the sessions).
Any one know any such setting for ksoap2-android, that will allow me to consume the
WCF service keeping my session intact on the server.
Currently when i make a new call to the service, the sessionid gets changed and all my
session variables clear out and loose their values.
View 1 Replies
View Related
Sep 25, 2010
Can anyone please recommend a training session/course for Android graphics API/OpenGL ES?
View 1 Replies
View Related
Aug 4, 2010
For example, I want my users to be able to click a button "Get new quote" which will start a new row in the the database for data to start being stored, but I'm unsure of how to store activity independent (or cross activity) data, like the _id of the row, which I will need to requery and update the row when new data becomes available on subsequent activities. What's the name of this mechanism and how is it done?
View 1 Replies
View Related
Oct 15, 2010
I'm developing an app using android 2.1. I have a problem with using session cookies to login to a RESTful web service. The code works fine on the emulator, but when I run it on my HTC Magic, the cookie logic doesn't work. I've confirmed that the magic is receiving cookies in the headers by listing them (see attached). Can anyone say why the cookie store would be empty even tho they are in the headers?
View 1 Replies
View Related
Apr 21, 2010
I'm writing an application consisting of several activities and, on restarts, I'd like the application to initially display the application's activity that was the last to display in the application's previous session.
I save information about the last activity in SharedPreferences and I'm trying to start that last activity with a call to startActivity(intent) from my Application's onCreate handler.
The problem is that if I don't set the intent's FLAG_ACTIVITY_NEW_TASK, the result is a run-time exception message in logcat suggesting that I should set the flag. And if I set that intent flag, the correct activity gets started but doesn't fully initialize resulting in null pointer exceptions (which don't occur when I don't attempt to start the activity from my Application class).
CODE:...........
Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
How to correctly start a particular activity from the Application class's onCreate handler?
View 3 Replies
View Related
Apr 23, 2010
The Facebook application that came loaded on my Droid has been working fine for 2 months. This afternoon, at first I couldn't access anything that had posted since this morning. Now I can't get anything at all. I keep getting an error message: "102/Session Key invalid or no longer valid" And it even happens when I try to go to my profile!
View 7 Replies
View Related
Jan 9, 2010
We're designing an Android app that has several activities which are working in a wizard like way - user should pass from the activity #1 to activity #5 to get to the final activity (#6).
Since we know an activity can be suddenly terminated by OS on low memory we used Application class as a static storage for keeping the data the user inputs on "wizard" activities and other data our app needs for the whole session.
Unfortunately we've discovered this approach fails - looks like the Application class instance is also can be killed by OS (this was specifically discovered on Android 1.6 versus 1.5). Are our expectations wrong on this approach (we think Application class instance always lives for the whole app session)?
So the question is - what is the best practices on Android to keep data between activities deathes/restarts for the whole application session?
View 2 Replies
View Related
Nov 22, 2010
I just ran through the Unrevoked process, which ended in the software telling me, "This was a triumph". I am, however, unconvinced.I can not boot into any other recovery than the stock HTC recovery and therefore can not perform a Nand Back up or flash Unrevoked Forever.I'm running a newer Evo with 2.2, it has hboot 2.02 and is showing S-ON. Is this the problem?
View 34 Replies
View Related
Jun 27, 2012
I have an Android application which connects to my desktop via SSH when I load it, it works fine. When I click a button on the interface on my phone, it sends a command through the SSH connection to be executed on my desktop, that works fine also. The problem is I have one class that opens the connection and sends all the commands through. I call this class from my onCreate method with button listeners.
So I have my class Init which opens the connection when the program starts, then I have a button listener for button_1 which calls
Code:
Init.send("mkdir "test_directory");
No problem, that works great but what if I want to have a button on another screen? How can I get the same Init object to maintain the open session with my desktop? If I create a new Init object in the other class it will reconnect on a new session but I want to use the same one.
So I'm wondering how I can (for example):
1. launch application, create Init object and call Init.connect(username, password, port, host)
2. click a button and use button listener to call Init.send("mkdir test_directory")
3. click a button and load a new screen with new buttons
4. this loads a new .java class with a new onCreate method to manage the new display with new buttons (is this necessary?)
------------everything works up to here--------------
5. click one of the new buttons managed by the new class but use the same session created in the original class from the original Android screen
To explain exactly what I'm doing, screen 1 has a button which loads screen 2. Screen 2 has a list of directories on the remote machine. Screen 3 has a list of directories inside the directory clicked on screen 2. I want to send a request for the directories on screen 2 using the Init object created from screen 1 which was displayed on launch.
View 2 Replies
View Related