Page 1 of 1

Problems with client-connect/client-disconnect script

Posted: Mon Jan 30, 2017 12:56 am
by goku
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

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

Posted: Mon Jan 30, 2017 1:44 am
by disqualified
goku wrote:it works perfectly when I "manually" execute it from command line
  • me too ..

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

Posted: Mon Jan 30, 2017 1:48 am
by goku
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.

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

Posted: Mon Jan 30, 2017 2:04 am
by disqualified
I guess your script is written by a grasshopper

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

Posted: Mon Jan 30, 2017 9:34 am
by goku
Yea.... thanks for your effort, no need to further spam this thread with supercool "I'm gonna teach you" posts...

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

Posted: Mon Jan 30, 2017 3:33 pm
by TinCanTech