Module: kamailio
Branch: master
Commit: b4cf8f6819ddb89b572fe25e778baaad53a6e081
URL: 
https://github.com/kamailio/kamailio/commit/b4cf8f6819ddb89b572fe25e778baaad53a6e081

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2019-04-08T10:33:22+02:00

websocket: added check mechanism based on tcp connection

- type 3 (KEEPALIVE_MECHANISM_CONCHECK)
- based on GH #1892

---

Modified: src/modules/websocket/ws_frame.c
Modified: src/modules/websocket/ws_frame.h

---

Diff:  
https://github.com/kamailio/kamailio/commit/b4cf8f6819ddb89b572fe25e778baaad53a6e081.diff
Patch: 
https://github.com/kamailio/kamailio/commit/b4cf8f6819ddb89b572fe25e778baaad53a6e081.patch

---

diff --git a/src/modules/websocket/ws_frame.c b/src/modules/websocket/ws_frame.c
index 840125a041..36b465bc65 100644
--- a/src/modules/websocket/ws_frame.c
+++ b/src/modules/websocket/ws_frame.c
@@ -812,6 +812,14 @@ void ws_keepalive(unsigned int ticks, void *param)
                        if(wsc->state == WS_S_CLOSING || wsc->awaiting_pong) {
                                LM_WARN("forcibly closing connection\n");
                                wsconn_close_now(wsc);
+                       } else if (ws_keepalive_mechanism == 
KEEPALIVE_MECHANISM_CONCHECK) {
+                               tcp_connection_t *con = tcpconn_get(wsc->id, 0, 
0, 0, 0);
+                               if(con==NULL) {
+                                       LM_INFO("tcp connection has been 
lost\n");
+                                       wsc->state = WS_S_CLOSING;
+                               } else {
+                                       tcpconn_put(con);
+                               }
                        } else {
                                int opcode = (ws_keepalive_mechanism == 
KEEPALIVE_MECHANISM_PING)
                                                                 ? OPCODE_PING
diff --git a/src/modules/websocket/ws_frame.h b/src/modules/websocket/ws_frame.h
index d2cfe3a577..d0f8d84ed0 100644
--- a/src/modules/websocket/ws_frame.h
+++ b/src/modules/websocket/ws_frame.h
@@ -40,7 +40,8 @@ enum
 {
        KEEPALIVE_MECHANISM_NONE = 0,
        KEEPALIVE_MECHANISM_PING = 1,
-       KEEPALIVE_MECHANISM_PONG = 2
+       KEEPALIVE_MECHANISM_PONG = 2,
+       KEEPALIVE_MECHANISM_CONCHECK = 3
 };
 #define DEFAULT_KEEPALIVE_MECHANISM KEEPALIVE_MECHANISM_PING
 extern int ws_keepalive_mechanism;


_______________________________________________
Kamailio (SER) - Development Mailing List
[email protected]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to