HTTP error 401 Android device only

This issue happens on Android device only, it works fine in simulators and on ios devices. I am doing a network call and my server is replying with http error 401. on the android device, there is a low-level java exception and it is not bubbled up so I cannot do anything about it. does anyone have a workaround for this? I need to get the error to respond to it, as I am able to in the other cases I mentioned.

I/System.out(28802): ERROR: Received authentication challenge is null
W/System.err(28802): com.naef.jnlua.LuaRuntimeException: ?:0: attempt to concatenate field ‘response’ (a nil value)
W/System.err(28802):     at com.naef.jnlua.LuaState.lua_pcall(Native Method)
W/System.err(28802):     at com.naef.jnlua.LuaState.call(Unknown Source)
W/System.err(28802):     at com.ansca.corona.CoronaLua.dispatchEvent(CoronaLua.java:90)
W/System.err(28802):     at network.NetworkRequest$LuaCallback$1.executeUsing(NetworkRequest.java:598)
W/System.err(28802):     at com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:153)
W/System.err(28802):     at com.ansca.corona.events.EventManager.sendEvents(EventManager.java:229)
W/System.err(28802):     at com.ansca.corona.Controller.updateRuntimeState(Controller.java:223)
W/System.err(28802):     at com.ansca.corona.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:399)
W/System.err(28802):     at com.ansca.corona.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1622)
W/System.err(28802):     at com.ansca.corona.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1377)
 

What version of Corona SDK are you running?

Is there anything that would cause your server to send your android device to another page/server based on useragent? and that new URL might have a password on it?

What all versions of Android have you tried it on?

I was using the released Corona build but to be sure I upgraded to the most recent build 10/15 and the result is exactly the same.

One device we are testing is Android 4.3, the other is a Kindle Fire I cant find the version on that. 

This case is the login event. Our app is attempting to log in the user and the server is failing the login, returning error 401. Our lua code handles this, as I indicated in the report, in the simulator and on ios devices the networking code is working I am able to pick up the error 401 and deal with it. But only on Android device the error never comes back and we see this internal java error when we trace using adb.

Thank you for your help,

–John

I’ve heard back from the engineers and the error is likely coming from your code.  This is the tell:

com.naef.jnlua.LuaRuntimeException: ?:0: attempt to concatenate field ‘response’ (a nil value)

Your event being returned by network.request() doesn’t have a response field set.  This could happen if you get a timeout and isError is true.  You need to trap for that situation. 

You can also build with the debug.keystore and your stack trace will show file and line numbers.  You can also turn on showRuntimeErrors in your config.lua.  See:  http://docs.coronalabs.com/guide/basics/configSettings/index.html#runtime-errors

Also on iOS and the Simulator, what is the contents of your response field? Is it an empty string?

What version of Corona SDK are you running?

Is there anything that would cause your server to send your android device to another page/server based on useragent? and that new URL might have a password on it?

What all versions of Android have you tried it on?

I was using the released Corona build but to be sure I upgraded to the most recent build 10/15 and the result is exactly the same.

One device we are testing is Android 4.3, the other is a Kindle Fire I cant find the version on that. 

This case is the login event. Our app is attempting to log in the user and the server is failing the login, returning error 401. Our lua code handles this, as I indicated in the report, in the simulator and on ios devices the networking code is working I am able to pick up the error 401 and deal with it. But only on Android device the error never comes back and we see this internal java error when we trace using adb.

Thank you for your help,

–John

I’ve heard back from the engineers and the error is likely coming from your code.  This is the tell:

com.naef.jnlua.LuaRuntimeException: ?:0: attempt to concatenate field ‘response’ (a nil value)

Your event being returned by network.request() doesn’t have a response field set.  This could happen if you get a timeout and isError is true.  You need to trap for that situation. 

You can also build with the debug.keystore and your stack trace will show file and line numbers.  You can also turn on showRuntimeErrors in your config.lua.  See:  http://docs.coronalabs.com/guide/basics/configSettings/index.html#runtime-errors

Also on iOS and the Simulator, what is the contents of your response field? Is it an empty string?