Hello everyone,
I’m facing an issue with my MikroTik Hotspot setup on RouterOS v7. Some of my hotspot users are being disconnected before their assigned expiration time (e.g., 1-day profiles).
Here’s what I’ve configured so far:
Idle Timeout: Set to none.
Keepalive Timeout: Tried various settings, including 10m and 1d.
Session Timeout: Set to 00:00:00 (disabled).
Uptime Limit: Set to the correct duration, such as 1d.
Despite this, users are still expiring prematurely. I’ve also ensured that the router’s time is accurate and synchronized via NTP.
Has anyone else encountered this problem on RouterOS v7? Any advice on what might be causing this or how to resolve it would be greatly appreciated!
on login script
#*****************************************************************************************
:put (",remc,1920,1d,0,,Enable,");
:local validity "1d"; #unit: m=mins, h=hours , d=days
:local price "1920"; #price(for sales report - optional to update)
:local tlimit "1d"; #unit(for sales report - optional to update): m=mins, h=hours , d=days
:local lockmac "YES"; #selection: YES/NO
:local addsales "YES"; #selection: YES/NO
# Modify above script values only
###############################################################################
:local date [ /system clock get date ]; :local time [ /system clock get time ]; :local addtime ($time + $validity); :local days ($addtime / 24h); :local ndays ($days * 24h); :local exptime ($addtime - $ndays); :local comment [ /ip hotspot user get $user comment]; :local hsProfile [/ip hotspot user get $user profile]; :local mac $"mac-address"; :if ([:pic $comment 3] = "/" and [:pic $comment 6] = "/") do={} else={ :local mdays {31;28;31;30;31;30;31;31;30;31;30;31}; :local months {"01"=1;"02"=2;"03"=3;"04"=4;"05"=5;"06"=6;"07"=7;"08"=8;"09"=9;"10"=10;"11"=11;"12"=12}; :local monthr {"jan";"feb";"mar";"apr";"may";"jun";"jul";"aug";"sep";"oct";"nov";"dec"}; :local tday [:tonum [:pick $date 8 10]]; :local tyear [:tonum [:pick $date 0 4]]; :local actmonths {"01"="jan";"02"="feb";"03"="mar";"04"="apr";"05"="may";"06"="jun";"07"="jul";"08"="aug";"09"="sep";"10"="oct";"11"="nov";"12"="dec"}; :local dd [:tonum [:pick $date 8 10]]; :local yy [:tonum [:pick $date 0 4]]; :local month [:pick $date 5 7]; :local year [ :pick $date 0 4 ]; :local mm (:$months->$month); :set dd ($dd+$days); :local dm [:pick $mdays ($mm-1)]; :if ($mm=2 && (($yy&3=0 && ($yy/100100 != $yy)) || $yy/400400=$yy) ) do={ :set dm 29 }; :while ($dd>$dm) do={ :set dd ($dd-$dm); :set mm ($mm+1); :if ($mm>12) do={ :set mm 1; :set yy ($yy+1);}; :set dm [:pick $mdays ($mm-1)]; :if ($mm=2 && (($yy&3=0 && ($yy/100100 != $yy)) || $yy/400400=$yy) ) do={ :set dm 29 }}; :local Tmonth (:$actmonths->$month); :local vdate "$[:pick $monthr ($mm-1)]/"; :if ($dd<10) do={ :set vdate ($vdate."0") }; :set $vdate "$vdate$dd/$yy"; :local zero ""; :if ( [len $tday] = 1) do={:set zero "0";}; /ip hotspot user set comment="$vdate $exptime" [find where name=$user]; :if ($lockmac = "YES") do={ /ip hotspot user set mac-address=$mac [find where name=$user];}; :if ($addsales = "YES") do={ /system script add name="$Tmonth/$zero$tday/$tyear-|-$time-|-$user-|-$price-|-$address-|-$mac-|-$tlimit-|-$hsProfile-|-$comment" owner="$Tmonth$year" source="$Tmonth/$zero$tday/$tyear" comment=mikhmon;};}
###############################################################################
scheduler script
:local hsprofile "24hours"; #hotspot user profile
# Modify above script values only
###############################################################################
:foreach i in [ /ip hotspot user find where profile=$hsprofile ] do={ :local comment [ /ip hotspot user get $i comment]; :local name [ /ip hotspot user get $i name]; :local gettime [:pic $comment 12 20]; :local getmonth [:pic $comment 0 3]; :local getday [:tonum [:pic $comment 4 6]]; :local getyear [:tonum [:pic $comment 7 11]]; :if ([:pic $comment 3] = "/" and [:pic $comment 6] = "/") do={ :local vmonths {"jan"=1;"feb"=2;"mar"=3;"apr"=4;"may"=5;"jun"=6;"jul"=7;"aug"=8;"sep"=9;"oct"=10;"nov"=11;"dec"=12}; :local tmonths {"01"=1;"02"=2;"03"=3;"04"=4;"05"=5;"06"=6;"07"=7;"08"=8;"09"=9;"10"=10;"11"=11;"12"=12}; :local date [ /system clock get date ]; :local time [ /system clock get time ]; :local dd [:tonum [:pick $date 8 10]]; :local yy [:tonum [:pick $date 0 4]]; :local month [:pick $date 5 7]; :local mm (:$tmonths->$month); :local getmm (:$vmonths->$getmonth); :if (($getyear < $yy) or ($getyear <= $yy and $getmm < $mm) or ($getyear <= $yy and $getmm <= $mm and $getday < $dd) or ($getyear <= $yy and $getmm <= $mm and $getday <= $dd and $gettime < $time)) do={ [ /ip hotspot user remove $i ]; [ /ip hotspot active remove [find where user=$name] ];}}}
###############################################################################