0

I want to remove active hotspot users with below code but says :

no such item

mikrotik.Send("/ip/hotspot/active/remove");
mikrotik.Send("=.id=" + username,true);

below is screenshot of mikrotik hotspot enter image description here

SajjadZare
  • 2,487
  • 4
  • 38
  • 68

1 Answers1

4

The best way to do this is finding the correct .id of the active hotspot user by doing ...

/ip/hotspot/active/print

You will receive a List of Active Users like this:

[tag=3, data={idle-time=6s, uptime=47s, bytes-out=121490,.id=*AC100016, mac-address=2C:AE:2B:9A:22:37, packets-out=314, session-time-left=59m13s, login-by=http-chap, bytes-in=47381, address=172.16.0.22, radius=false, server=SERVER_TEST, user=0872test, packets-in=330}]

In this case, the .id you need is .id=*AC100016

Now, I give you and example of my method deleteActiveUser() . It has benn done in Java but in my opinion it's clear:

public boolean deleteActiveUser(String id_param){
        boolean ret = true;
        try {
            StringBuilder sb = new StringBuilder();
            sb.append("/ip/hotspot/active/remove .id=");
            sb.append(id_param);

            this.getConnection(this.mikrotik).execute(sb.toString());

            } catch (MikrotikApiException e) {
                ret = false;
            e.printStackTrace();

        } catch (NullPointerException ex) {
            ex.printStackTrace();
            ret = false;

        } finally {

            closeConnection();
        }

        return ret;

    }
Droideka
  • 41
  • 4