Problems with client-connect/client-disconnect script

How to customize and extend your OpenVPN installation.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
goku
OpenVpn Newbie
Posts: 3
Joined: Mon Jan 30, 2017 12:47 am

Problems with client-connect/client-disconnect script

Post by goku » Mon Jan 30, 2017 12:56 am

Hey guys,

I'm using auth-user-pass-verify, client-connect and client-disconnect to handle some database related stuff for my openvpn server. This works perfectly so far but now I'm having some big trouble for hours with my connect and disconnect script.

Code: Select all

client-connect 		       "/usr/bin/php scripts/connect.php"
client-disconnect 		"/usr/bin/php scripts/disconnect.php"
Inside both scripts I'm doing some database related stuff, now I wanted to extract information from "openvpn-status.log" to get information about bandwith usage but this is where my problems start.
First I tried using fopen(), but this causes the php script to "hang", when I do "ps -U openvpn" I see a running php process that never stops and freezes the whole VPN server.
Afterwards I tried to use fsockopen() to connect to the management interface, to get my information from there but this gives me the exact same result.

When I remove fopen()/fsockopen() the script runs perfectly. Funny thing is, that the script also works perfectly when I do it like this from command line:

Code: Select all

common_name="xyz" php scripts/disconnect.php


Anways, as soon as OpenVPN itself executes the script the mentioned problems start to happen, somehow this is related to fopen() and fsockopen() but I have no idea what the reason is and why it works perfectly when I "manually" execute it from command line.

Thanks in advance and best regards

User avatar
disqualified
OpenVPN User
Posts: 40
Joined: Fri Jun 03, 2016 7:13 pm

Re: Problems with client-connect/client-disconnect script

Post by disqualified » Mon Jan 30, 2017 1:44 am

goku wrote:it works perfectly when I "manually" execute it from command line
  • me too ..

goku
OpenVpn Newbie
Posts: 3
Joined: Mon Jan 30, 2017 12:47 am

Re: Problems with client-connect/client-disconnect script

Post by goku » Mon Jan 30, 2017 1:48 am

When I execute for example disconnect.php with fopen() or fsockopen() in it from command line using sth like:

Code: Select all

php scripts/disconnect.php
What I want to say is, that the script itself works and has no bugs, but OpenVPN somehow is not able to excute it without causing the script to hang and freeze even the openvpn process.

User avatar
disqualified
OpenVPN User
Posts: 40
Joined: Fri Jun 03, 2016 7:13 pm

Re: Problems with client-connect/client-disconnect script

Post by disqualified » Mon Jan 30, 2017 2:04 am

I guess your script is written by a grasshopper

goku
OpenVpn Newbie
Posts: 3
Joined: Mon Jan 30, 2017 12:47 am

Re: Problems with client-connect/client-disconnect script

Post by goku » Mon Jan 30, 2017 9:34 am

Yea.... thanks for your effort, no need to further spam this thread with supercool "I'm gonna teach you" posts...

TinCanTech
OpenVPN Protagonist
Posts: 11137
Joined: Fri Jun 03, 2016 1:17 pm

Re: Problems with client-connect/client-disconnect script

Post by TinCanTech » Mon Jan 30, 2017 3:33 pm


Post Reply