Skip to content

Support for resume/pauseMonitor via Websocket. #6142

@leg03

Description

@leg03

⚠️ Please verify that your question has not already been reported

🛡️ Security Policy

📝 Describe your problem

I would like to resume or Pause Monitors via Websocket with ms JS Code. In the source code I found a Websocket Call for the front end functionality:

resumeMonitor() {
            this.$root.getSocket().emit("resumeMonitor", this.monitor.id, e => {
                this.$root.toastRes(e)
            }
            )
        },
        pauseMonitor() {
            this.$root.getSocket().emit("pauseMonitor", this.monitor.id, e => {
                this.$root.toastRes(e)
            }
            )

and I already have a working websocket call for e.g. adding a monitor:

     async addMonitor(monitorData) {
        return new Promise((resolve, reject) => {
            this.socket.emit('add', monitorData, (response) => {
                if (response.ok) {
                    console.log('Monitor added successfully');
                    resolve(response);
                } else {
                    console.error('Failed to add monitor:', response.msg);
                    reject(response);
                }
            });
        });
    }

so my question now is, how can I get my code running:

    async pauseMonitor(id) {
        return new Promise((resolve, reject) => {
            this.socket.emit('pauseMonitor', id, (response) => {
                console.log('Logging TEst'); //the logging what I am talking about beneath the code
                if (response.ok) {
                        console.log('####');
                        resolve(response);
                    } else {
                        console.log('##');
                        reject(new Error(response.msg));
                    }
            });
        });
    }

I already tried to get some idea where it is still working and where not. So after the "new Promise" part, the console log was given out. But when it is added after the socket emit call, I don't get anything back.

📝 Error Message(s) or Log

Just not getting any response

🐻 Uptime-Kuma Version

1.23.16

💻 Operating System and Arch

Windows 11 x64

🌐 Browser

Google Chrome

🖥️ Deployment Environment

  • Runtime Environment:
    • Node.js: Version 24.6.0
    • Filesystem:
      • Windows: NTFS/ReFS
    • Storage Medium: SSD
  • Uptime Kuma Setup:
    • Number of monitors: 5 or so

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions