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