Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3981910
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:28:00+00:00 2026-05-20T05:28:00+00:00

I am tring to connect a remote server via openvpn using C#. I am

  • 0

I am tring to connect a remote server via openvpn using C#. I am able to connect it successfully. but disconneecting seems to not work properly.
Once I close my app, I am not able to access the internet. I got to manually disable the TAP Adapter and then enable to execute the app again.
I checked my “route print” and yes Tap is coming ahead of internet and hence couldn’t access net.

I connect using :
openvpn –config client.ovpn –ca certificate.cer –auth-user-pass user.txt

My disconnecting code is :

    public void DisconnectServer()
    {
        // Write the logs
        if (sb != null)
            IOUtility.WriteToFile(sb.ToString(), "ConnectionLogs.log");
        processInfo = null;
        if (process != null)
        {
            //process.Close();
            if (!process.HasExited)
            {
                process.CancelOutputRead();
                ProcessThreadCollection ptc = process.Threads;
                Console.WriteLine("////// PROCESSED THREAD = " + ptc.Count);
                for (int i = 0; i > ptc.Count; i++)
                {
                    ProcessThread pt = ptc[i];
                    pt.Dispose();
                    ptc.Remove(pt);
                    Console.WriteLine("REmoed Thread @ " + i);
                }
                process.CloseMainWindow();
                process.Kill();
            }
        }

        sb = null;
        connected = false;
    }

On searching net for this issue, I found to use management to exit the openvpn safely. But I cannot make how to run the managemetn code. While start I added :
openvpn –config ca.ovpn –ca cert.cer –management 127.0.0.1 12345
Then how to give SIGTERM signal to close the openvpn.
In new cmd, I tried : openvpn –management-signal SIGTERM but things doesn’t work.

OpenVpn will not be installed as a Service, so I guess can’t use –service attribute.

Can anyone guide me where am I going wrong in disconnecting. How to handle the managemetn-signal code.
Which is the best way to disconnet from openvpn server. Can I also exit the openvpn itself ?

Kindly help me. Have searched a lot on internet and found some help but no sucess yet. Stuck on this issue.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:28:01+00:00Added an answer on May 20, 2026 at 5:28 am

    Thanks to all,

    I found the solution and this is how I suceeded :

                foreach (Process p in Process.GetProcesses())
            {
                if (p.ProcessName.StartsWith("openvpn"))
                {
                    p.Kill();
                    Console.WriteLine("Killed Process");
                    break;
                }
            }
    

    Instead of working with its thread and all, the above code helped out to solve the problem.

    I hope this helps others too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to connect to my mysql database on a remote server (via
I'm trying to connect to a remote MySQL server via SSH in my Java
I am trying to connect to a remote MySQL database using Visual C# 2008
I am trying to connect to a Microsoft SQL 2005 server which is not
I am trying to connect to a remote servre via FTP in my VB
Trying to connect to a SQL Server 2005 instance remotely but getting the following
I am trying to connect to Postgre using a PHP script, but it returns
I'm trying to connect to a remote database (hosted on Netfirms www.netfirms.ca if anyone
I'm trying to use cygwin sqlplus to connect to a remote oracle installation located
When trying to connect to an ORACLE user via TOAD (Quest Software) or any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.