2

I would like to know what exactly the differences are between a WLAN connection to the internet, or a 3G connection to the internet.

I am coding an App which uses session handling, which works fine when I'm connected via WLAN, but not at all when I'm connected via 3G. How can that be? Is there something I need to be aware of that I am not?

deimos1988
  • 5,896
  • 7
  • 41
  • 57

2 Answers2

3

For accessing the internet, Android doesn't do anything special relating to the type of connection you're using.

However, there are some potential reasons why your session-handling mechanism may not work:

  • the mobile network you're on may filter out certain packets or items, such as HTTP headers, that your app uses for session tracking
  • if you started a session while on WLAN, then continue your session over a mobile connection, the server will see you have a different IP address - this could cause the server to see you as a separate user
  • similarly, the mobile network could be presenting a different IP to the server with each connection you make from the phone

How does the session-handling mechanism work?
Do you have access to the server so that you could identify any differences between the two types of requests?

Christopher Orr
  • 110,418
  • 27
  • 198
  • 193
  • Thank you for your answer. Well, I am using the kSoap for Android library to establish a connection, and the sessions are handled by a "ServiceConnection", where I can set properties, in this case, a cookie. As I stated in my initial post, it is working fine with a wlan-connection, but not at all when connected to the internet via 3G. – deimos1988 Jul 30 '11 at 23:22
0

I figured out what the problem was. When calling the webservice, I am receiving "HeaderProperties", and one of them contains the cookie I need. When connected via WLAN, I get the cookie with HeaderProperties.get(2).getValue(). However when connected via 3G, .get(2) only contains a timestamp, to get the cookie, I need to get the fourth entry (i.e. HeaderProperties.get(3).getValue()).

deimos1988
  • 5,896
  • 7
  • 41
  • 57
  • 2
    If you can, try to use a method that allows fetching header property by key rather than by index, otherwise it is likely to change and break your application. – Martin Foot Jul 31 '11 at 11:18
  • 1
    So it sounds like what I said in my answer about 3G networks modifying HTTP headers (i.e. Set-Cookie) was right then... ;) – Christopher Orr Jul 31 '11 at 12:40
  • @Martin Foot Right now I am checking whether the value contains "JSESSIONID", but your method sounds way more elegant; I think I'll try that! – deimos1988 Jul 31 '11 at 14:52
  • @Christopher You're right, I didn't really know what you meant when you first wrote it, now I do :) – deimos1988 Jul 31 '11 at 14:52