Browse code

core: Make sure that responses to requests received on a WebSocket are sent on existing connections

- WebSocket servers cannot create connections to WebSocket clients - so
this setting is essential.
- It does exactly the same thing as using set_reply_no_connect() in
kamailio.cfg - but this way it is always on (as it must be) for
WebSockets.

Peter Dunkley authored on 29/06/2012 22:05:48
Showing 1 changed files
... ...
@@ -172,9 +172,9 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
172 172
 		/* check for the alias stuff */
173 173
 #ifdef USE_TCP
174 174
 		if (msg->via1->alias && cfg_get(tcp, tcp_cfg, accept_aliases) && 
175
-				(((rcv_info->proto==PROTO_TCP) && !tcp_disable)
175
+				(((rcv_info->proto==PROTO_TCP || rcv_info->proto==PROTO_WS) && !tcp_disable)
176 176
 #ifdef USE_TLS
177
-					|| ((rcv_info->proto==PROTO_TLS) && !tls_disable)
177
+					|| ((rcv_info->proto==PROTO_TLS || rcv_info->proto==PROTO_WSS) && !tls_disable)
178 178
 #endif
179 179
 				)
180 180
 			){
... ...
@@ -185,7 +185,12 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
185 185
 			}
186 186
 		}
187 187
 #endif
188
-			
188
+
189
+		/* Force connection reuse for responses if the message arrived on a
190
+		   WebSocket */
191
+		if (rcv_info->proto==PROTO_WS || rcv_info->proto==PROTO_WSS)
192
+			msg->rpl_send_flags.f |= SND_F_FORCE_CON_REUSE;
193
+
189 194
 	/*	skip: */
190 195
 		DBG("preparing to run routing scripts...\n");
191 196
 #ifdef  STATS