0

I'm using C# .Net with SuperSimpleTCP Library to make a simple messaging app. The App works just fine in Normal circumstances. But if the client is connected to a VPN(cisco openconnect) Client will fail to communicate with the server. not only messages will fail to successfully transmit to the server, but the server will fail to register the Client's disconnection in the event of the Client closing the app

Minimalist Client Code:

private void Client_Form_Load(object sender, EventArgs e)
{
       IPAddress iPAddress = IPAddress.Parse(IP_Address);
       client = new SimpleTcpClient(iPAddress,25565);
       client.Connect();
}

private void btnSend_Click(object sender, EventArgs e)
{
         if(!client.IsConnected)return;
            if (string.IsNullOrEmpty(txtMessage.Text)) return;
            client.Send(Message);
}

Minimalist Server Code:

 private void Server_Form_Load(object sender, EventArgs e)
        {
            server = new SimpleTcpServer(txtIP.Text);
         server.Start();
            client.Events.Connected += Events_Connected;
            client.Events.Disconnected += Events_Disconnected;
            client.Events.DataReceived += Events_DataReceived;

        }
private void Events_ClientConnected(object? sender, ConnectionEventArgs e)
        {
        this.Invoke((MethodInvoker)delegate
            {
                txtInfo.Text += $"{e.IpPort}: Connected...{Environment.NewLine}";
            });
     }

private void Events_ClientDisconnected(object? sender, ConnectionEventArgs e)
        {
            this.Invoke((MethodInvoker)delegate
            {
                txtInfo.Text += $"{e.IpPort}: Disconnected...{Environment.NewLine}";
            });
        }
private void Events_DataReceived(object? sender, DataReceivedEventArgs e)
        {
            this.Invoke((MethodInvoker)delegate
            {
                txtInfo.Text += $"{e.IpPort}: {Encoding.UTF8.GetString(e.Data)}{Environment.NewLine}";
            });

        }

I don't know what about using a VPN causes the issue and how to fix it.

Edit: It is important that my app can't run with a VPN running in the background cause I live in Iran. and using VPN is almost necessary while using the internet in any way

  • The Cisco AnyConnect will get its orders from the firewall to which it connects. Normally, a company will configure the firewall to disable split-tunneling, meaning the ability to for the host to use any network other than the tunnel creat4ed by AnyConnect, because split-tunneling is a security risk to the company. You will need to convince the company to allow split-tunneling. In any case, this is not actually a programming question, so it is off-topic here. – Ron Maupin Dec 31 '22 at 14:24
  • You need a route to the server. You can test if there is a route using PING. A route could be blocked by a firewall. You may need to use the server name instead of IP. Most cases you can use the Computer Name instead of the IP. Many networks do not use IP routing and instead lookup the Computer by Name. – jdweng Dec 31 '22 at 15:41

0 Answers0