Shashank
Shashank

Reputation: 249

How many total TCP connections are created for web socket call from browser to apache http server to web service

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?

Upvotes: 4

Views: 568

Answers (1)

covener
covener

Reputation: 17896

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.

Upvotes: 4

Related Questions