lightbody / browsermob-proxy

A free utility to help web developers watch and manipulate network traffic from their AJAX applications.
http://bmp.lightbody.net
Apache License 2.0
2.16k stars 653 forks source link

WebSocket upgrade requests cause proxy to hang #415

Open jpereira06 opened 8 years ago

jpereira06 commented 8 years ago

I'm using proxy (2.1.0-beta-5) with selenium(2.53.0)&Firefox(44).

I'm facing a very strange issue. I run tests over hundreds of web pages, and sometimes the driver hangs and does not return the execution till timeout is fired due to onload event is never fired: window.performance.timing.loadEventEnd property is 0.

I noticed that when the driver hangs usually is when it is loading a web that contains "zopim" chat.

I wrote a Junit test(attached) in order to isolate the problem and also noticed that when I run the selenium driver without proxy all works fine but when I add the proxy the driver hangs.

Some samples of webs that causes this issue are:

"http://mundoalfombra.com/" "http://vikinguard.com" "https://dormia.es/

jpereira06 commented 8 years ago

SeleniumBugTest.java.zip

jpereira06 commented 8 years ago

Please find attached standard output:

eclipse.log.zip

jekh commented 8 years ago

Thanks for this report, @jpereira06. I can reproduce this issue consistently. It appears to be caused by special handling of the HTTP 101 status code for websocket upgrade requests in littleproxy. The issue appears to ultimately stem from a bug in netty. I'll open the appropriate PRs and get them fixed for the next release.

Good catch! Thanks.

waseemh commented 8 years ago

did you try disabling MITM ?

jekh commented 8 years ago

@jpereira06 - this should be fixed in the just-released beta-6. Could you give it a try?

jpereira06 commented 8 years ago

It works in most of cases but sometimes is still hanging. e.g. http://mundoalfombra.es and http://vikinguard.com hangs most of times.

For cases when it works properly, like http://dormia.es, I noticed that the load time is about 20%-25% bigger than when I load the same web in the same browser (no caches, no cookies, etc..) without proxy. Is it normal?

jekh commented 8 years ago

I'm not sure why it would be longer. I wasn't able to reproduce the issue you describe; every time I visited those sites, it loaded properly, even after refreshing repeatedly with cache disabled. What browser are you using?

jpereira06 commented 8 years ago

Firefox31. With 2.1.0-beta-7-SNAPSHOT I get the same behaviour. Are not you able to reproduce it with the junit I've provided?

jekh commented 8 years ago

@jpereira06 - I'm not able to reproduce this issue, no. The websites you listed load fine for me. You say you're using Firefox 31, which is pretty old; are you able to reproduce against a modern version of Firefox?

jpereira06 commented 8 years ago

@jekh I've updated to:

The following junit is still hanging for "http://mundoalfombra.com/" and "https://vikinguard.com" but not always. It only produces timeout sometimes. I've run it and the first 3-5 executions worked properly but then I started getting timeouts (30 secs) most of time. Are you not able to reproduce it?

SeleniumBugTest.java.zip

jpereira06 commented 8 years ago

@jekh I'm pretty sure that it only hangs when zopim chat is enabled. I can enable zopim chat in vikinguard.com for your tests when you want.