ICE Android connection issue

in Help Center
Hi, I'm new to using ICE and I've been working on a client-side application. I know the server side code is good because the iPhone client my team has developed works with it fine.
The issue I'm having is when I run with the debugger everything works fine (eclipse debugger), but when I run normally I get a ConnectFailedException. It makes me think there is some sort of synchronization issue but I have no clue what it is. Here is the code I use and the stacktrace:
Stack:
03-23 21:47:10.566: ERROR/GPSNetwork(447): Ice.ConnectFailedException
03-23 21:47:10.566: ERROR/GPSNetwork(447): error = 0
03-23 21:47:10.566: ERROR/GPSNetwork(447): at IceInternal.Network.doFinishConnect(Network.java:388)
03-23 21:47:10.566: ERROR/GPSNetwork(447): at IceInternal.TcpTransceiver$1.run(TcpTransceiver.java:35)
03-23 21:47:10.566: ERROR/GPSNetwork(447): at java.lang.Thread.run(Thread.java:935)
Any help at all would be very much appreciated.
The issue I'm having is when I run with the debugger everything works fine (eclipse debugger), but when I run normally I get a ConnectFailedException. It makes me think there is some sort of synchronization issue but I have no clue what it is. Here is the code I use and the stacktrace:
try { ic = Ice.Util.initialize(); proxy = ic.stringToProxy("Echter:default -h serverIP -p 8842"); Echter.EchterServicePrxHelper.checkedCast(proxy); Log.v("GPSNetwork","Connected!"); }catch (ConnectFailedException e){ Log.e("GPSNetwork","Failed to connect. Application now exiting."); Log.e("GPSNetwork",Log.getStackTraceString(e)); e.printStackTrace(); System.exit(1); }catch (Ice.LocalException e) { e.printStackTrace(); }
Stack:
03-23 21:47:10.566: ERROR/GPSNetwork(447): Ice.ConnectFailedException
03-23 21:47:10.566: ERROR/GPSNetwork(447): error = 0
03-23 21:47:10.566: ERROR/GPSNetwork(447): at IceInternal.Network.doFinishConnect(Network.java:388)
03-23 21:47:10.566: ERROR/GPSNetwork(447): at IceInternal.TcpTransceiver$1.run(TcpTransceiver.java:35)
03-23 21:47:10.566: ERROR/GPSNetwork(447): at java.lang.Thread.run(Thread.java:935)
Any help at all would be very much appreciated.
0
Comments
03-25 01:24:31.605: WARN/System.err(355): [ 3/25/09 01:24:31:607 Network: trying to establish tcp connection to 198.145.73.17:8842 ]
03-25 01:24:31.685: WARN/System.err(355): [ 3/25/09 01:24:31:688 Network: failed to establish tcp connection
03-25 01:24:31.695: WARN/System.err(355): local address = 0.0.0.0:-1
03-25 01:24:31.695: WARN/System.err(355): remote address = <not connected>
03-25 01:24:31.705: WARN/System.err(355): Ice.ConnectFailedException
03-25 01:24:31.705: WARN/System.err(355): error = 0 ]
03-25 01:24:31.715: WARN/System.err(355): [ 3/25/09 01:24:31:718 Network: shutting down tcp connection for reading and writing
03-25 01:24:31.715: WARN/System.err(355): local address = 0.0.0.0:-1
03-25 01:24:31.715: WARN/System.err(355): remote address = <not connected> ]
03-25 01:24:32.175: WARN/System.err(355): [ 3/25/09 01:24:32:180 Network: closing tcp connection
03-25 01:24:32.185: WARN/System.err(355): local address = 0.0.0.0:-1
03-25 01:24:32.195: WARN/System.err(355): remote address = <not connected> ]
03-25 01:24:32.255: WARN/System.err(355): [ 3/25/09 01:24:32:261 Network: trying to establish tcp connection to 198.145.73.17:8842 ]
03-25 01:24:32.285: WARN/System.err(355): [ 3/25/09 01:24:32:282 Network: failed to establish tcp connection
03-25 01:24:32.285: WARN/System.err(355): local address = 0.0.0.0:-1
03-25 01:24:32.295: WARN/System.err(355): remote address = <not connected>
03-25 01:24:32.295: WARN/System.err(355): Ice.ConnectFailedException
03-25 01:24:32.295: WARN/System.err(355): error = 0 ]
03-25 01:24:32.335: WARN/System.err(355): [ 3/25/09 01:24:32:331 Network: shutting down tcp connection for reading and writing
03-25 01:24:32.345: WARN/System.err(355): local address = 0.0.0.0:-1
03-25 01:24:32.345: WARN/System.err(355): remote address = <not connected> ]
Odd thing is that it runs just fine with the debugger. Also, one of the guys developing has a really slow laptop that runs it just fine. I will test it on the G1 tomorrow.
-edit: I adjusted the timeout property but it didn't affect anything.
based on the following timestamps, it's only being given less than a tenth of a second to connect.
03-25 01:24:31.605: WARN/System.err(355): [ 3/25/09 01:24:31:607 Network: trying to establish tcp connection to 198.145.73.17:8842 ]
03-25 01:24:31.685: WARN/System.err(355): [ 3/25/09 01:24:31:688 Network: failed to establish tcp connection
By the way the timeouts in the prior post get set using the setProperty method on InitializationData and is then used to create the communicator.
checkedCast and uncheckedCast are quite different:
- uncheckedCast is a purely local operation: you provide a proxy of one type and Ice manufactures locally a proxy of another type with the same identity and addressing information
- checkedCast, on the other hand, sends a message to the server (ice_isA) and returns either a proxy of the requested type (if the target object is indeed of that type) or 0 (if it's not) or an Ice exception (if the target object is unreachable).
So it's not surprising to see uncheckedCast work (it works all the time) and checkedCast fail.
Cheers,
Bernard
- Android applications work correctly in the debugger but not outside the debugger (although both are running in the emulator)
- You have not tried on a real device.
Is this is the case with all machines? Or is it just one single server?
I think at this point I'd start trying to capture TCP traffic on the emulator host and see exactly what is going on at the TCP level.
Do you know how I would go about viewing more in-depth info on TCP traffic on the android?
TCP connections are getting closed? :-(
Here is when I run in the debugger and connection succeeds:
IPhone and G1 are using 3.3. Reason being is because the newer version needs to be built from source. Possibly android was affected and iceTouch wasn't? Anyways, the server team is currently compiling the source and updating to 3.3 and I'll post the results as soon as we get it tested. (Crosses fingers).
Android version 1.1_r1
and we've tried both with ice 3.3.0 and 3.3.1
I also made a simple program just to debug this issue and it's having the same error:
can't set tcp buffer sizes: FileNotFoundException
I'll look into this some more...
Please apply the patch to the IceAndroid-0.1.0 distribution, and rebuild IceAndroid.jar. You can do that by:
After rebuilding, ensure you refresh your Eclipse project to pick up the changes to the .jar file before re-running the application. If you have problems applying the patch, or building please email [email protected], and I'll send you a pre-compiled jar file.
Unfortunately, because I cannot reproduce the issue its hard to say whether it is the cause of your issue, or whether the attached patch fixes the problem.
I don't get any problems like that with my emulator. What hardware platform are you using?