Prechádzať zdrojové kódy

modules/websocket: Make sure that all WebSocket messages are sent on connections that already exist

- This is the same as using set_forward_no_connect() and
  set_reply_no_connect() in kamailio.cfg.  But this means it will
  always happen automatically for WebSocket messages.
- This is important as a WebSocket server cannot create connections -
  so we always have to use one that already exists.
Peter Dunkley 13 rokov pred
rodič
commit
636a6dabd1
1 zmenil súbory, kde vykonal 5 pridanie a 0 odobranie
  1. 5 0
      modules/websocket/ws_frame.c

+ 5 - 0
modules/websocket/ws_frame.c

@@ -260,6 +260,11 @@ static int encode_and_send_ws_frame(ws_frame_t *frame, conn_close_t conn_close)
 		from = &local_addr;
 	}
 
+	/* Regardless of what has been set before _always_ use existing
+	   connections for WebSockets.  This is required because a WebSocket
+	   server (which Kamailio is) CANNOT create connections. */
+	dst.send_flags.f |= SND_F_FORCE_CON_REUSE;
+
 	if (tcp_send(&dst, from, send_buf, frame_length) < 0)
 	{
 		STATS_TX_DROPS;