Forum Xamarin.Android

Tcp Client connection issue with T-mobile and s9


I have an app that has been working fine for a couple of years now. Last week I found an issue that ONLY happen (so far) in T Mobile with an S9 phone. The call the TcpClient.Connect is stuck and timeout.
Again this just happen in an S9 from T Mobile with the WIFI off, As soon as I connect the WIFI the issue does not happen.

This is my code:
var tcpc = new TcpClient();
tcpc.Connect( remoteAddress, remotePort);

I have tested both versions of Connect with the address (above) and using the IP:

        if (System.Text.RegularExpressions.Regex.Match( remoteAddress , @"\d+\.\d+\.\d+\.\d+").Success)
            tcpc.Connect(IPAddress.Parse( remoteAddress ), remotePort);

In both cases it fails.

Any idea would be greatly appreciated.



  • ArindamSarkarArindamSarkar Member ✭✭

    @NauraGalarde it could be because Mobile provider does not allow IP Address. Try domain name instead of IP and Port. Mobile providers gradually moving towards IPv6 from IPv4.

  • NauraGalardeNauraGalarde USMember ✭✭
    edited July 2018

    This is the entire code. I am using both ways

    tcpc = new TcpClient();
                    string trimmed = connectTo.Trim();
                    if (System.Text.RegularExpressions.Regex.Match(host, @"\d+\.\d+\.\d+\.\d+").Success)
                        tcpc.Connect(IPAddress.Parse(host), remotePort);
                        tcpc.Connect(host, remotePort);
  • Ahsan_SiddiqueAhsan_Siddique PKMember ✭✭✭✭
    edited July 2018

    Follow my working way, maybe this example can help you.

  • NauraGalardeNauraGalarde USMember ✭✭

    Thank you. I actually saw you code a few days a go and base on that I did some changes in my code. But, when I run your code in my phone (S9 + T-Mobile) I have to click on "Connect" button twice and in the second request the connection is established. That's using TcpClient.ConnectAsync. Do you know why?

Sign In or Register to comment.