4

I would like to know how many TCP connections are created when WebSocket call is made from browser to apache http server to backend web service?

Does it create a separate TCP connection from the browser to apache http server and from apache to the web service?

Shashank
  • 249
  • 2
  • 13

1 Answers1

4

When Apache is proxying websockets, there is 1 TCP connection between the client and Apache and 1 TCP connection between Apache and the backend.

Apache watches both connections for activity and forwards read from one onto the other.

This is the only way it can be in a layer 7 (Application Layer, HTTP) proxy. Something tunnelling at a much lower layer, like a NAT device or MAC forwarding IP sprayer could tunnel a single connection -- but not on the basis of anything higher up in the stack like headers.

The 2nd connection is observable with netstat.

The 2nd connection is opened when mod_proxy_wstunnel calls ap_proxy_connect_to_backend() which calls apr_socket_create() which calls the portable socket() routine. When recent releases of mod_proxy_http handle this tunneling automatically, simialr flow through ap_proxy_acquire_connection.

covener
  • 17,402
  • 2
  • 31
  • 45