Hi,
Thank you for your patience. I am very happy someone can help me. Now I made some progress.
I find out what the problem is now. In the query you provided I need to put quotes around radacct. Like this:
query = "SELECT IFNULL(TIME_TO_SEC(TIMEDIFF(NOW(), MIN(AcctStartTime))),0) FROM `radacct` WHERE UserName='%{%k}' ORDER BY AcctStartTime LIMIT 1;"
Now, have one more problem.
My NAS (Mikrotik) is not receiving the Session-Timout. I cannot see it in the NAS log. I only can see Acct-Session-Time. Therefore it is not terminating the session. For testing I have set the time limit to 60 seconds.
Freeradius is sending it:
(2) dailycounter : Sent Reply-Item for user hello, Type=Session-Timeout, value=60
(2) [dailycounter] = ok
Sending Access-Challenge of id 232 from 10.1.1.2 port 135 to 27.33.228.125 port 47097
Session-Timeout = 60
EAP-Message = 0x010200061920
Message-Authenticator = 0x00000000000000000000000000000000
State = 0x543a9074553889da6f504855ab4e7a4b
(2) Finished request 2.
I did not put anything in the radreply for the user. When I did put Session-Timeout=60 in radreply, I still cannot see it in the NAS log.
Is it my a problem with NAS configuration?
What should I do now?
Jake He