Behavior of websocket handleServerUpgrade

Hi all,
I am building a new node and was learning about the way the core websocket nodes are built.
I created a websocket listener for some test paths, examples
/test1 and /test2
I used them for testing and then I deleted those listeners from the node configuration and restarted node-red.

Now my expectations is that those listeners should be gone for good but I noticed that the function
handleServerUpgrade used in 22-websocket.js is still gets called for those deleted paths. I have no clue on how it is still referencing those deleted paths.

See below..
I just inserted a console.log in place below and my console showed repeatedly
here is the function from 22-websocket.js

    function handleServerUpgrade(request, socket, head) {

        const pathname = url.parse(request.url).pathname;
        console.log('handleServerUpgrade for ' + pathname);
        if (listenerNodes.hasOwnProperty(pathname)) {
            listenerNodes[pathname].server.handleUpgrade(request, socket, head, function done(ws) {
                listenerNodes[pathname].server.emit('connection', ws, request);
            });
        } else {
            // Don't destroy the socket as other listeners may want to handle the
            // event.
        }
    }

this is what I see on the console log. continuously the below lines are printed.

handleServerUpgrade for /test1
handleServerUpgrade for /test2
handleServerUpgrade for /test1
handleServerUpgrade for /test2

Any thoughts about the reason why this is happening ? Am I missing something ?
Could the reason be that we don't destroy the socket?
Thank you

You have deleted the node - but have you deleted the config node as well ?
menu - configuration nodes - unused

@dceejay Thank you! I am glad I asked the question. I had to delete the config node from the Configuration List found on the side bar only.
What I actually initially did when deleting those config nodes, is used the Edit button next to the Path field from the websocket-in node config, and then the Delete button on the top bar of the config node! This has removed it from the list and so I assumed the config nodes were gone. This is what I become used to in all other nodes I suppose.
I did not realise that the config node still exist there actually ! Thanks for pointing out . this is little different than what I expected when I deleted the config node though !

And that will have deleted the config nodes - there's nothing particular about the websocket nodes to behave differently in that regard.

You can delete it by selecting in the Config nodes panel on the rhs and then clicking Delete key.
For the future you can tell that you have unused config nodes as when you deploy, in the popup that appears saying successfully deployed there is a message telling you that you have some unused, and a link to click that will take you straight there.

@knolleary Just made a few tests and you are right there nothing different than the others.. I "think" where the confusion came from at the start is because the node has two modes "Listen" and "Connect To" and each one has different configuration but it is shown from the same screen. I might have got confused or so for some reason , but I use the two modes for web socket in, and web socket out all around ..
In all cases, all good now .. thanks for reply!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.