Signal-Android icon indicating copy to clipboard operation
Signal-Android copied to clipboard

MMS sending (and receiving) fails if on WiFi and APN is set to IPv6

Open apmon opened this issue 12 years ago • 38 comments

Hello,

I am having trouble sending and receiving MMS on my T-Mobile USA Samsung galaxy S4 (Android 4.4.4) while connected to WiFi. I am using TextSecure 2.1.8.

It looks like the problems have something to do with the switch from IPv4 (on WiFi) to IPv6 on the cellular network.

If I manually disable WiFi and send a MMS through TextSecure on the IPv6 only APN, the MMS is correctly sent and received.

If I manually switch the APN to IPv4 only, then TextSecure correctly sends and receives MMS while connected to WiFi (by transitioning to the cellular network to send the MMS).

However, if I use the default APN of the phone (IPv6 only) and I am connected to the IPv4 only WiFi, sending fails. The logs show that TextSecure attempts to connect to the cellular, but then times out connecting to the MMSC (2607:7700:0:5::ab8:4b81) because of Network unreachable.

apmon avatar Sep 19 '14 18:09 apmon

The log of the failed sending of MMS can be found at http://pastebin.com/dPGgm4vn

I can also provide logs of the successful sending on mobile IPv6 network, and successful sending on WiFi with IPv4 only APN if that is of any help.

apmon avatar Sep 19 '14 18:09 apmon

Can't reproduce, it works for me, even with Wifi on.

... which is kind of weird because requestRouteToHost only supports IPv4 so our logic skips that step entirely. Makes me wonder what that's even good for if it works without it.

@apmon the error in your logs is that the network is unreachable. Is this maybe an IPv6 compatibility problem with the network you're connected to via Wifi, or there was otherwise bad connectivity?

mcginty avatar Sep 22 '14 19:09 mcginty

The WiFi I am connect to does not have any IPv6 capabilities at all. So if it is trying to reach a IPv6 via the WiFi, it would likely get a no route to host. However, the mobile network does have a IPv6 connectivity and the signal is strong at the location I tried it at. (Confirmed, as it works when the wifi is off and when the APN is set to IPv4 only).

Given that as you say, the requestRouteToHost only works with IPv4, is it possible, that TextSecure correctly enables the cellular MMS network. That then resolved the DNS to an IPv6. But because it isn't calling requestToRoute, android will preferably try and route via the WiFi, which fails due to lack of IPv6 capabilities.

Is there no equivalent call to requestRouteToHost that actually works with IPv6?!

Would it be worth posting this question to the T-Mobile IPv6 forum to ask if there is a bug in the routing code when both IPv4 only WiFi and IPv6 only LTE is activated? ( https://groups.google.com/forum/#!forum/tmoipv6beta )

apmon avatar Sep 22 '14 20:09 apmon

@mcginty If you don't call requestRouteToHost for an address, traffic will be transmitted over the wifi interface rather than the radio interface.

moxie0 avatar Sep 22 '14 20:09 moxie0

Well the weird thing is it looked like it was going over my LTE radio and not wifi. Could be that the OS had already setup a route automatically given it's my default APN?

mcginty avatar Sep 22 '14 21:09 mcginty

I didn't specify in my earlier post, but the IPv6 APN also works over LTE for me (wifi disabled).

mcginty avatar Sep 22 '14 21:09 mcginty

Do you also have a Samsung S4 with Android 4.4.4? Does your WiFi support IPv6? Could there be some timing issue, that it hasn't yet finished setting up all of the routes yet when TextSecure tries to access the MMS server? Is there a way to try and determine trough which interface it is trying to establish the connection and what the current routing table looks like on the device? Just some random thoughts of why it might work on your device, but not on mine...

apmon avatar Sep 22 '14 21:09 apmon

Tested on a Nexus 5 w/ 4.4.4, the wifi I tested on does not support IPv6 making it even less likely it accidentally went over that network.

As far as I'm aware, all routing information is privileged information, so we can't really do much in-app.

mcginty avatar Sep 22 '14 21:09 mcginty

@apmon if you have time and want to provide a bit more diagnostic info, install https://play.google.com/store/apps/details?id=org.whispersystems.mmsmonster and email me or post the results here, otherwise I can't reproduce this myself so don't have a path forward. Closing for now, pending a reopen with more data.

mcginty avatar Oct 13 '14 02:10 mcginty

Hello,

OK, here are the logs from the MMS monster:

WiFi connected, IPv6 APN: gist.github.com/ed7c5bac60e741c13e08 WiFi disconnected, IPv6 APN: gist.github.com/657aa2fdb5a1239c0108 WiFi connected, IPv4 APN: gist.github.com/21982dd9555af23923bb

Hope those help in any way.

Let me know if there is anything else I can do.

On 10/12/2014 08:03 PM, Jake McGinty wrote:

@apmon https://github.com/apmon if you have time and want to provide a bit more diagnostic info, install https://play.google.com/store/apps/details?id=org.whispersystems.mmsmonster and email me or post the results here, otherwise I can't reproduce this myself so don't have a path forward. Closing for now, pending a reopen with more data.

— Reply to this email directly or view it on GitHub https://github.com/WhisperSystems/TextSecure/issues/1937#issuecomment-58835589.

apmon avatar Oct 15 '14 04:10 apmon

Awesome, thanks so much @apmon

mcginty avatar Oct 15 '14 04:10 mcginty

Yeah, there's something just borked with the IPv6 APN. I found a hidden method, requestRouteToHostAddress that supports IPv6, used reflection to call that instead, and the HTTP call still failed. Then I wrote a custom DNS resolver that only chooses the IPv4 address with the hopes that that would work, still no dice.

mcginty avatar Oct 15 '14 07:10 mcginty

I'm having the exact same issues on my T-Mobile Note 4. Is there any point to posting logs? Or has this been determined to be entirely a problem on T-Mobile's side?

mitchellmebane avatar Dec 22 '14 21:12 mitchellmebane

Does anyone know if the situation improves with Android 5 and its new way to handle multiple networks ( https://developer.android.com/about/versions/android-5.0.html#Wireless )? I.e does Android 5.0 now finally handle IPv6 only networks in this respect correctly? And if yes, does it help with the issues on the T-mobile USA IPv6 network? Given that I am able to send MMS on the IPv6 APN, as long as WiFi was disabled, it seems that the T-mobiles network it self (at least under some conditions), works correctly.

apmon avatar Dec 22 '14 23:12 apmon

I can confirm the exact behavior on a Nexus 5 running Android 5.0 on T-Mobile:

  • MMS works when phone is connected to LTE and network APN set to IPv4
  • MMS works when phone is connected to LTE and network APN set to IPv6
  • MMS works when phone is connected to WiFi and network APN set to IPv4
  • MMS fails when phone is connected to WiFi and network APN set to IPv6

By default, my T-Mobile APN is set to IPv6, so from my perspective, MMS just doesn't work in TextSecure when I'm connected to WiFi. I had no idea why until I finally got so frustrated that I searched the issue tracker and found this issue.

I suspect nearly everyone in this situation just thinks MMS doesn't work, or was maybe attentive enough to deduce that they had to disconnect from WiFi and has been living with it (like me). I think this one merits a quick fix.

konklone avatar Dec 31 '14 17:12 konklone

@konklone Thanks for confirming.

Although I actually meant something slightly differently. I was wondering if the new Connectivity APIs in Android 5 allow to solve this issue. So you will need to rewrite some code to test this, and therefore the devs (@mcginty ?) will need to try this out at some point. (I don't have an Android 5 phone and I haven't yet tried to compile TextSecure myself, so I can't do this).

apmon avatar Jan 06 '15 19:01 apmon

I tested the Android 5 MMS APIs and it solves both IPv6 and Wi-Fi issues on Lollipop. Good news, will have something out soon for that.

mcginty avatar Jan 06 '15 19:01 mcginty

Oh great!

Now we only need to wait for a couple of years until people's phone are actually running Lollipop... ;-)

apmon avatar Jan 06 '15 19:01 apmon

@apmon I think he meant he will have a fix for earlier android too. @mcginty are we slated for a release sometime soon?

jeremymasters avatar Jan 06 '15 19:01 jeremymasters

so does the fix bind to the cell interface when it sees internal reserved IPs resolved for the mms server, or...? seeing the same problem here, nexus 5 stock 4.4.4 on wifi, the DNS lookup of tmobile mms server answer is 10.x which of course can't be reached over any network but tmobile... etc..

johnrandolph avatar Feb 24 '15 16:02 johnrandolph