Abu

Nadir Aliyev nadir at azstarnet.az
Thu Mar 13 08:32:02 CET 2014


Hello,

I use rlm_sql module and have problems with stale sessions.

Sometimes users (more than 4k-5k) disconnects without
accounting_stop_query and they can't connect again because session is
not closed by normal way and session still active in database. My
accounting time is 45 minutes, if new alive-update packets not coming
for user from NAS side I close this session manually with a little
script. After this process (after 45 minute) user can connects again. I
used stale_sessions but it not helped.

In my case I want to close for user existing staled session in database
if new accounting_start_query (insert query) occurs. How can i realize
this?


accounting_start_query = "INSERT into ${acct_table1} \
                (AcctSessionId, AcctUniqueId, UserName, Realm,
NASIPAddress, NASPortId, NASPortType, AcctStartTime, AcctAuthentic, \
                ConnectInfo_start, CalledStationId, CallingStationId,
ServiceType, FramedProtocol, FramedIPAddress, AcctStartDelay,
XAscendSessionSvrKey, mac_address, agent, vlan) \
                values('%{Acct-Session-Id}',
'%{Acct-Unique-Session-Id}', '%{SQL-User-Name}', '%{Realm}',
'%{NAS-IP-Address}', \
                '%{NAS-Port}', '%{NAS-Port-Type}', ('%S'::timestamp -
'%{%{Acct-Delay-Time}:-0}'::interval), '%{Acct-Authentic}',
'%{Connect-Info}', \
                '%{Called-Station-Id}', '%{Calling-Station-Id}',
'%{Service-Type}', '%{Framed-Protocol}', \
                NULLIF('%{Framed-IP-Address}', '')::inet, 0,
'%{X-Ascend-Session-Svr-Key}', \
                (case when length('%{client-mac-address}')>0 then
'%{client-mac-address}' else '%{Calling-Station-Id}' end), \
                (case when '%{NAS-IP-Address}' = '10.10.10.10' then
'%{Nas-Port-Id}' else '%{circuit-id-tag}' end), \
                '%{Nas-Port-Id}')"

accounting_start_query_alt  = "UPDATE ${acct_table1} \
                SET AcctStartTime = ('%S'::timestamp -
'%{Acct-Delay-Time:-0}'::interval), AcctStartDelay = 0, \
                ConnectInfo_start = '%{Connect-Info}' WHERE
AcctSessionId = '%{Acct-Session-Id}' AND UserName = '%{SQL-User-Name}' \
                AND NASIPAddress = '%{NAS-IP-Address}' AND AcctStopTime
IS NULL"



Thanks!
Nadir
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeradius.org/pipermail/freeradius-users/attachments/20140313/270ded55/attachment.html>


More information about the Freeradius-Users mailing list