[sr-dev] Fwd: RPC command to close all WS connections.

Henning Westerholt hw at skalatan.de
Mon May 25 15:18:10 CEST 2020


Hi Andrey,

as you know, there is an RPC command ws.close() and also a script function to close sessions remotely. So, it should be certainly possible to close the sessions over RPC.

Not being the author of this particular module, it is hard to say why it crashes. Try the usual debugging techniques, e.g. gdb to find more clues.

If you have a working version, please open a pull request. In case of more questions, just ask on this list again.

Cheers,

Henning

--
Henning Westerholt – https://skalatan.de/blog/
Kamailio services – https://gilawa.com<https://gilawa.com/>

From: sr-dev <sr-dev-bounces at lists.kamailio.org> On Behalf Of Andrey Deykunov
Sent: Monday, May 18, 2020 1:02 PM
To: Kamailio (SER) - Development Mailing List <sr-dev at lists.kamailio.org>
Subject: [sr-dev] Fwd: RPC command to close all WS connections.


---------- Forwarded message ---------
От: Andrey Deykunov <deykunov at gmail.com<mailto:deykunov at gmail.com>>
Date: пн, 18 мая 2020 г. в 12:24
Subject: RPC command to close all WS connections.
To: Daniel-Constantin Mierla <miconda at gmail.com<mailto:miconda at gmail.com>>

Hi Daniel,

We're using two nodes (active and passive) of our PBX server in production. When an active node becomes passive, we should forcibly close all WS connections, established by clients on this node. So, I've added 'ws.close_all' command to websocket module to let our failover service be able closing WS connections remotely.

I've added the following code to ws_frame.c:

void ws_rpc_close_all(rpc_t *rpc, void *ctx)
{
    ws_connection_t **list = NULL, **list_head = NULL;
    ws_connection_t *wsc = NULL;
    int ret;

    list_head = wsconn_get_list();
    if(!list_head)
        return;

    list = list_head;
    wsc = *list_head;
    while(wsc) {
        LM_WARN("Closing connection\n");
        ret = close_connection(&wsc, LOCAL_CLOSE, 1000, str_status_normal_closure);
        wsc = *(++list);
    }
    wsconn_put_list(list_head);
}

but I think this code may be unsafe and could corrupt shared memory, because I've got some segfaults during failovers after adding this command.

What do you think? Is it possible to close connections properly and safety for shared memory?

Thanks,
Andrey






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20200525/d9076b84/attachment-0001.html>


More information about the sr-dev mailing list