Open SadafShafi opened 4 years ago
Do you have openvpn running and exposing management interface on localhost tcp 7505? Keep in mind any firewalls you may have in place.
Thanks for the reply No, i dont have any of such things running along
I am getting the same problem and I have No Firewall Please HELP!
Send your OpenVPN configuration and your code.
I also can not connect. My OpenVPN configuration file is located in the current working directory, and in C:\X\OpenVPN\config. The config file is:
client
dev tun
proto udp
remote bcn-239.whiskergalaxy.com 443
nobind
auth-user-pass
resolv-retry infinite
auth SHA512
cipher AES-256-CBC
comp-lzo
verb 2
mute-replay-warnings
remote-cert-tls server
persist-key
persist-tun
key-direction 1
<ca>
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
</ca>
<tls-auth>
-----BEGIN OpenVPN Static key V1-----
...
-----END OpenVPN Static key V1-----
</tls-auth>
To connect, I'm doing
import openvpn_api
v = openvpn_api.VPN('bcn-239.whiskergalaxy.com', 443)
v.connect()
But I receive a time out error. I can connect using the OpenVPN GUI, but I would like to have a Python interface.
@rcolpo Add another entry to your config like this:
management localhost 7505
And then connect to it this way:
v = openvpn_api.VPN('localhost', 7505)
Thank you @HosseyNJF. I changed the config file like the one below:
client
dev tun
proto udp
remote bcn-239.whiskergalaxy.com 443
management localhost 7505
nobind
auth-user-pass
resolv-retry infinite
auth SHA512
cipher AES-256-CBC
comp-lzo
verb 2
mute-replay-warnings
remote-cert-tls server
persist-key
persist-tun
key-direction 1
<ca>
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
</ca>
<tls-auth>
-----BEGIN OpenVPN Static key V1-----
...
-----END OpenVPN Static key V1-----
</tls-auth>
Then, I tried to connect like this:
import openvpn_api
v = openvpn_api.VPN('localhost', 7505)
v.connect()
But I got the error:
No connection could be made because the target machine actively refused it
I can no longer connect using the OpenVPN GUI.
@rcolpo Are you running both the python code and the OpenVPN server on the same machine?
<openvpn_api.vpn.VPN object at 0x7f85e86d8430>
Traceback (most recent call last):
File "1.py", line 12, in
any help??
I ran this script
import openvpn_api.vpn v = openvpn_api.vpn.VPN('localhost', 7505) v.connect() print(" ______________ connected _______________") print(v.release) v.disconnect()
and this is the error I got
Traceback (most recent call last): File "vpn123.py", line 5, in <module> v.connect() File "C:\Users\sadaf\AppData\Local\Programs\Python\Python38-32\lib\site-packages\openvpn_api\vpn.py", line 63, in connect raise errors.ConnectError(str(e)) from None openvpn_api.util.errors.ConnectError: [WinError 10061] No connection could be made because the target machine actively refused it