browsermob-proxy icon indicating copy to clipboard operation
browsermob-proxy copied to clipboard

TTL timer is not reset on proxy activity

Open mmirold opened this issue 6 years ago • 0 comments

To reproduce start browsermob-proxy with the argument "-ttl 30" and spawn a new proxy instance, e.g. to port 8081. Use the created proxy instance every 5 seconds, e.g. by executing while sleep 5; do curl -x http://localhost:8081 http://example.com; done.

At this point, I expect that the proxy can be used indefinitely because the expiration timer is reset every 5 seconds. What happens instead is that after 30 seconds the proxy socket disappears. The following message is logged: net.lightbody.bmp.proxy.ProxyManager] (expired-proxy-cleanup-thread) Expiring ProxyServer on port 8081 after 30 seconds without activity.

The existing test cases don't cover this logic. After a quick glance over the code it seems to me that the TTL mechanism relies on a Guava cache eviction strategy in ProxyManager, where cache eviction (and hence proxy expiration) is only prevented when some part of the code actively retrieves the proxy from the ProxyManager cache. It seems that this doesn't happen in the request handling code and hence cache eviction is not deferred.

mmirold avatar Oct 28 '19 12:10 mmirold