jcricket/gwt-syncproxy

Login to deployed App fails with java.io.FileNotFoundException (due to mishandled HTTP 500 error)

Opened this issue · 2 comments

What steps will reproduce the problem?
1. Deploy app to App Engine.
2. Attempt to login using following code:
    LoginUtils.setLoginUrl("https://<my app>.appspot.com");
    LoginUtils.loginAppEngine( this, cookie_manager_avail_listener, chosen_account ) ;

Notes:
1. I have used this URL with a token generated with code similar to the 
implementation at 
http://blog.notdot.net/2010/05/Authenticating-against-App-Engine-from-an-Android
-app, using chosen_account - seems to work.
2. I've replaced my app's name with <my app> just in this issue entry.
3. "this" above is my Activity subclass.
4. Deployed App Engine server works fine (no HTTP 500s) when used with the GWT 
generated web client.

What is the expected output? What do you see instead?
Expected a successful login, got a thrown exception:

E/AndroidRuntime(13546): java.lang.RuntimeException: Failure in attempt to get 
cookie: 
E/AndroidRuntime(13546):    at 
com.gdevelop.gwt.syncrpc.android.GetCookieRunnable.run(GetCookieRunnable.java:12
1)
E/AndroidRuntime(13546):    at java.lang.Thread.run(Thread.java:841)
E/AndroidRuntime(13546): Caused by: java.io.FileNotFoundException: https://<my 
app>.appspot.com/_ah/login
E/AndroidRuntime(13546):    at 
com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLCon
nectionImpl.java:186)
E/AndroidRuntime(13546):    at 
com.android.okhttp.internal.http.HttpsURLConnectionImpl.getInputStream(HttpsURLC
onnectionImpl.java:246)
E/AndroidRuntime(13546):    at 
com.gdevelop.gwt.syncrpc.Utils.getResposeText(Utils.java:98)
E/AndroidRuntime(13546):    at 
com.gdevelop.gwt.syncrpc.android.GetCookieRunnable.run(GetCookieRunnable.java:98
)
E/AndroidRuntime(13546):    ... 1 more


What version of the product are you using? On what operating system?
SyncProxyAndroid-0.4.2.zip - GWT 2.6.0 - Released 2014-03-11

I am using the Google plugin in Eclipse on Ubuntu Linux.


Please provide any additional information below.

I have traced the error to here: 
https://code.google.com/p/gwt-syncproxy/source/browse/trunk/SPALibrary/src/com/g
develop/gwt/syncrpc/android/GetCookieRunnable.java#98

From what I can tell the server is returning HTTP 500, which means that the 
server crashed out, probably without generating output.  Since there is no 
input to open, we get an exception.

Original issue reported on code.google.com by rmar...@gmail.com on 1 Dec 2014 at 9:40

This problem is killing me too :(
I have spent lots of days looking for a workaround but getting nothing.

Im looking forward to someone who finds out a solution.

Thanks in advance.

Original comment by lunarjchav@gmail.com on 13 Jan 2015 at 5:52

Sorry for the delayed response. The code for logon to App Engine is a slightly 
modified port of the previous developer's solution and is unfortunately not 
well documented. I'm planning to clean up the App Engine credentials process 
for the next release (See [Roadmap] for 0.6) since it will be a bit of an 
overhaul. In the meantime, update to the new 0.5 release just in case some of 
the new Cookie management in 0.5 helps the issue. However, if that does not 
resolve the problem, please try the following and report back:

http://stackoverflow.com/questions/3919071/what-is-the-proper-url-to-get-an-auth
-cookie-from-a-gae-based-application/3929312#3929312

I believe the server may be failing (500) because the token is invalid. Follow 
the solution in that link to invalidate and re-fetch the token. I'll provide an 
automated mechanism within the the Android LoginUtils in 0.6 to handle this 
exception more cleanly. In the meantime, try this solution before the call to 
#loginAppEngine() and see if it makes a difference. Since the solution runs as 
an AsyncTask, make sure it completes before the call to #loginAppEngine(). Also 
if it fails, try to post the Server exception details from the Android call 
(especially since the GWT call doesn't make a 500, the Android call should be 
more identifiable).
Thanks

Original comment by p.pr...@blueesoteric.com on 15 Jan 2015 at 5:13

  • Changed state: Pending
  • Added labels: Priority-High, Milestone-Release0.6, Component-Logic, Usability
  • Removed labels: Priority-Medium