Archived

This forum has been archived. Please start a new discussion on GitHub.

iPhone client - Wifi vs. 3G question

Greetings,

I'm working on a prototype application as a learning exercise and I have a basic question regarding iPhone clients:

- Is there anything different or additional I need to do to get an iPhone client application to work over 3G vs. Wifi?

I have the following:
1. iPhone client app. (using IceTouch) communicating with a server application (Java) over Wifi. All functions work as expected, including callbacks from the server to the iPhone client. (Woohoo! Recently figured out the callback thing :D)
2. A router connected to the internet with port mapping configured to cover the ports used by my Ice application.

If I change the iPhone client's configuration to use the address of my router on the internet, and turn off Wifi the client application lingers for a while during initialization, then aborts. The odd thing is that I know I have "some" connectivity, because I can see the console messages on the server side indicating some of the initial function calls are served. This leads me to think maybe I'm missing some simple, basic thing.

I could not find anything specific to this in the documentation or doing a few searches on the forums, so I thought I would post the question to see if perhaps someone has already been through this already and can offer some tips that I might be missing.

Many thanks,
Ed

Comments

  • matthew
    matthew NL, Canada
    You shouldn't have to do anything special to get 3G to work. The fact that you get connectivity to the server shows that your application does in fact establish a connection to the server. What do you mean by aborts? What exactly occurs to your application?
  • When running on Wifi, the iPhone application screen comes up within a second or two, which means it received all data it needs from the server. This is some debug output to the console for the normal (Wifi) case:
    2009-09-13 16:06:19.726 TestApplication[449:207] Unit Table Count = 1
    (gdb) continue
    (gdb) continue
    2009-09-13 16:06:29.420 TestApplication[449:207] Cell Value
    kill
    quit
    
    The Debugger has exited with status 0.
    

    When running without Wifi, the application appears to "hang" with the black screen for a few minutes before exiting. I managed to capture console output for the same sequence of events as the "normal" case above. One thing that stands out is a line showing Ice::DNSException just prior a successful call to the server (needed to display the "Unit Table Count" value shown in the output). This is the console output for the 3G case:
    2009-09-13 16:07:37.634 TestApplication[457:207] Ice::DNSException
    2009-09-13 16:07:38.253 TestApplication[457:207] Unit Table Count = 1
    (gdb) continue
    (gdb) continue
    2009-09-13 16:10:23.894 TestApplication[457:207] *** Terminating app due to uncaught exception 'Ice::ConnectFailedException', reason: 'Transceiver.cpp:345: Ice::ConnectFailedException:
    connect failed: Operation timed out'
    2009-09-13 16:10:23.908 TestApplication[457:207] Stack: (
        808001701,
        805397928,
        405072,
        119179,
        129605,
        55265,
        815244828,
        815243892,
        814928848,
        814920984,
        814915840,
        848463104,
        848462364,
        848460676,
        848459700,
        848459360,
        814957300,
        814682524,
        814970032,
        814968048,
        814966908,
        839149932,
        807750263,
        807747947,
        814678868,
        814672532,
        54053,
        53916
    )
    terminate called after throwing an instance of 'ICEConnectFailedException'
    Program received signal:  “SIGABRT”.
    (gdb) 
    

    I'm still digging around and trying to see if I can optimize to reduce the amount of data I'm sending but the output above suggests something else is awry.

    Thanks!
    Ed
  • Is your server actually reachable via the public internet? The exception indicates that the client's connection attempt timed out. Remember, if you talk to the server via 3G, by definition, you are talking to it via the public internet. This means that the server must have a DNS entry (or, if it doesn't, the client must use the IP address of the server), and that the server must be reachable via the public internet.

    Cheers,

    Michi.
  • Thanks for the replies.

    The client is using the IP address of my router on the internet. It is reachable from the public internet. I also set up port mapping on the router to forward to my machine in my local network (my server uses port 9000, and I'm forwarding TPC and UDP ports 8000-10000 to my server machine).

    Note that there is activity on the server that indicates the first call the client made was successful (returned the data used by the client to log the "Unit Table Count = 1" message).

    Is it possible I need to do something to forward additional ports, os something along those lines?

    Ed
  • I don't know exactly how client and server are configured, but I suspect that your problem is related to that.

    I would run client and server with Ice.Trace.Network=2 and Ice.Trace.Protocol=1 and check the trace. This will probably give you the info you need to nail down the problem.

    Cheers,

    Michi.
  • matthew
    matthew NL, Canada
    When running without Wifi, the application appears to "hang" with the black screen for a few minutes before exiting.

    Unrelated to your question, if your application makes remote invocations of ay sort from the UI thread you will hang the UI. That is bad. What you should do is use AMI, or spawn a thread for more complex interactions. The IceTouch demos show how to do this.
  • matthew wrote: »
    Unrelated to your question, if your application makes remote invocations of ay sort from the UI thread you will hang the UI. That is bad. What you should do is use AMI, or spawn a thread for more complex interactions. The IceTouch demos show how to do this.

    Yes, but would that not also be a problem when running the application with Wifi? The application works with Wifi, but does not work without Wifi (ie. 3G).

    I'll try to run with more debug logging enabled as michi suggested to see if I can gather more info.

    Ed
  • matthew
    matthew NL, Canada
    Yes, but would that not also be a problem when running the application with Wifi? The application works with Wifi, but does not work without Wifi (ie. 3G).

    I wasn't really talking about this specific issue, I was more making a general observation. With wifi you are probably on a local network, so things will run much quicker and you might not notice any small hangs. However, once you start to use 3G things are slower, so hangs will become apparent.

    One thing that is directly related to your issue: Are you setting any timeout on your proxies? Perhaps you are getting timeout exceptions in the 3G case, and not in the local case.
  • First of all, thank you all very much for your help.

    I took Michi's advice and the client debug traces revealed what was probably an obvious issue to a non-noob. I think the short answer is: I need to learn how to use Glacier2.

    My first call to the server was working normally because my network router's port forwarding was sending request through as expected. One of the items returned to the client in that call is a proxy to another object. Naturally, this proxy has a local network address which obviously won't work. Guess which proxy was being used by the client for the second call . . .

    Thanks again!
    Ed