How does websocket stop the push of the last url after changing url

At the beginning of the

page, a websocket is requested

wsCurrentEntrust: function () { 
            if ("WebSocket" in window) {
                 websocket = new WebSocket(host + userId);
            }
            else {
                ...
            }
            websocket.onerror = function () {
                ...
            };
            websocket.onopen = function (event) {
                ...
            }
            websocket.onmessage = function (event) {
                ...
            }
            websocket.onclose = function () {
                ...
            }
        }

for example, the url of the ws I requested at first is host1, and then I click a button and then it becomes host2, but the message of host1 is still being pushed, resulting in a problem with the callback of the function. After solving how to change to host2, the message of host1 is no longer pushed ~

Mar.21,2021

websocket.onclose (), disconnects actively, and then recreates the websocket object based on the second url

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36003-2bfbf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36003-2bfbf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?