Android chat client loses connection

will_baylisswill_bayliss Member Will BaylissOrganization: University of PlymouthProject: Student Assignment Results Publication
Hi again.

I've got the chat server code built and working successfully on a local host and I can connect to this using the java and C++ clients running on other machines. For simplicity, I am NOT using SSL. I am using recent versions of all relevant software packages (Ice 3.4.2, Eclipse Indigo, newly downloaded and installed copies of ADB, Gnu Make etc.)

I've also built the Android client project, using Eclipse and ADB. The client can establish a connection with the public chat server at demo.zeroc.com. This works on the Android SDK emulator, an android x86 VM AND a physical device.

However, when I try to connect the Android chat client to the chat server/Glacier2 instance on my LAN, I'm seeing the following message:

Login failed: Ice.ConnectionLostException error = 0

(I should mention I'm aware that the SDK emulator will not connect to LAN hosts, so I'm not using this to test my own server).

I'm afraid the entry for this Exception in the Ice manual API reference doesn't shed a lot of light!

Running both the server application itself and Glacier 2 with network tracing (and security tracing) enabled is not particularly informative: The server is not reporting a connection at all and the Glacier2 router simply shows the tcp connection initially being accepted and then dropped within a few milliseconds:

-- 02/22/12 12:42:55.101 glacier2router: Network: accepted tcp connection
local address = 192.168.128.251:4502
remote address = 192.168.128.20:45046
-- 02/22/12 12:42:55.101 glacier2router: Network: sent 14 of 14 bytes via tcp
local address = 192.168.128.251:4502
remote address = 192.168.128.20:45046
-- 02/22/12 12:42:55.103 glacier2router: Network: received 14 of 14 bytes via tcp
local address = 192.168.128.251:4502
remote address = 192.168.128.20:45046
-- 02/22/12 12:42:55.103 glacier2router: Network: received 56 of 56 bytes via tcp
local address = 192.168.128.251:4502
remote address = 192.168.128.20:45046
-- 02/22/12 12:42:55.103 glacier2router: Network: closing tcp connection
local address = 192.168.128.251:4502
remote address = 192.168.128.20:45046

I'd be very grateful for any advice available: are there further diagnostic steps I might take?

Best Regards,

Will.

Comments

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    It sounds like the Glacier2 router is rejecting the connection. Can you try running Glacier2 with Glacier2.Client.Trace.Reject=1 and Glacier2.Trace.Session=1 to see if this gives more information?

    Cheers,
    Benoit.
  • will_baylisswill_bayliss Member Will BaylissOrganization: University of PlymouthProject: Student Assignment Results Publication
    At least the problem is better defined now!

    I'm very grateful for your help Benoit.

    Running with the suggested trace options is slightly more informative. I'm now seeing the following:

    -- 02/22/12 18:51:48.552 glacier2router: Glacier2: rejecting request. no session
    is associated with the connection.
    identity: Glacier2/router

    As before, I've tried the APK out on a couple of different emulators and a physical device. I can't see any difference between the session establishment mechanism used in the Java and Android clients. For test purposes, I'm using the chat server built from unmodified source code and it's working just fine with all the other clients (over TCP rather than SSL). I've also checked carefully through all of the relevant config files (more than once!)

    I do appreciate that most of the forum subscribers have plunged straight into coding for the framework from scratch and that I'm asking for help with a relatively trivial problem. However, the value of the sample code is that it gives less skilled developers - like me - a working codebase as a platform for initial experimentation. Android implementation is, unfortunately, particularly important for my purposes.

    So I would be very grateful indeed for any further guidance!

    Best Wishes,

    Will.
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    This usually indicates that the request was sent over a connection which isn't bound to a Glacier2 session. All the requests from the client to Glacier2 must be sent through the connection which used to create the Glacier2 session or otherwise Glacier2 rejects them. One common situation where this happens is when the client uses different connection timeouts for routed proxies (Ice opens different connections for each of the timeouts).

    Anyway, it's not clear to me what could be causing this in the Android chat client :). To figure out which request is being rejected, I suggest to enable the following tracing on the Glacier2 server and post the tracing here after trying to connect to Glacier2 with the Android client:
    Ice.Trace.Network=2
    Ice.Trace.Protocol=2
    Glacier2.Client.Trace.Reject=1
    Glacier2.Trace.Session=1
    

    With this tracing we'll see which connections are being opened to Glacier2 and for which requests.

    Cheers,
    Benoit.
  • will_baylisswill_bayliss Member Will BaylissOrganization: University of PlymouthProject: Student Assignment Results Publication
    Success! Sort of . . .

    Dear Benoit,

    Thanks! I ran the traces as suggested and could see that oddly, no session request was being received by the Glacier2 router following establishment of the TCP/IP connection. I began inspecting the source code and eventually noticed that the end-point name in lines 63 and 65 of AppSession.java is preconfigured as

    Glacier2/router

    The config.glacier2 files for the Chat Demo actually uses

    DemoGlacier2/router

    When the project is rebuilt with corrected end-point entries, session establishment takes place.

    However, the Android client does not display chatroom updates and attempting to send a message triggers Ice::OperationNotExistException

    So it looks very much like there is a version difference between the demo client and server. I'll compare the Slice definitions at each "end" and attempt to rebuild the client with a corrected definition. Then I'll let you know how I get on!

    Best Regards,

    Will.
  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi Will,

    Seems to me that you are using the chat server from cpp/demo/chat , the android chat client isn't designed to work with this server.

    You must use the Android chat client with the Chat Demo server available here ZeroC - Chat Demo - Download

    The chat server in this package is different from the one in Ice source distribution, this server uses "Glacier2.InstanceName=Glacier2" in the Glacier2 configuration files.

    This Chat Demo is described in detail in the Chat Demo web pages .

    We also have two articles that provide more detailed explanation of this Chat Demo, is recommended to read these articles if you are new to Ice.

    Let us know if you have further problems with this.
Sign In or Register to comment.