Comments (16)
Obvious. I was not supposed to set the "-port" flag.
from browsermob-proxy-py.
Hi,
I'm getting the same error on server.start()
Exception: Can't connect to Browsermob-Proxy
I also have the following:
from browsermobproxy import Server
server = Server("/Users/username/Desktop/browsermob-proxy/bin/browsermob-proxy")
server.start()
proxy = server.create_proxy()
Further on terminal, if I do /Users/username/Desktop/browsermob-proxy/bin/browsermob-proxy -port 9090
I get the following error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: net/lightbody/bmp/proxy/Main : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
It seems to be some issue with the version number, but not sure what exactly it is. Thanks.
from browsermob-proxy-py.
from browsermobproxy import Server
server = Server("browsermob-proxy-2.1.0-beta-3/bin/browsermob-proxy")
server.start()
proxy = server.create_proxy()
I run the four lines of codes and get the following error in the last line.
>>> proxy = server.create_proxy()
...
File "C:\Python27\lib\site-packages\requests\adapters.py", line 415, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', error(10054, 'An existing connection was forcibly closed by the remote host'))
I could run the four lines successfully for the first time, but after a reboot I always get this error message. The same happen in my second machine. Did I forget to release the resource or something in my first run?
from browsermob-proxy-py.
I am getting the same error when trying to run the following .py script:
`import os
from browsermobproxy import Server
server = Server("/Users/javaria/Desktop/browsermob-proxy-2.0-beta-6/bin/browsermob-proxy", options={'port': 9090})
server.start()
proxy = server.create_proxy()
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_proxy(proxy.selenium_proxy())
driver = webdriver.Firefox(firefox_profile=profile)
proxy.new_har("google")
driver.get("http://www.google.co.uk")
proxy.har # returns a HAR JSON blob
server.stop()
driver.quit()`
I am getting this error in console File "test1.py", line 6, in <module> server.start() File "/Users/javaria/Documents/projects/proxy-testing/browsermob-proxy-py/browsermobproxy/server.py", line 122, in start raise Exception(message) Exception: The Browsermob-Proxy server process failed to start. Check <open file '/server.log', mode 'w' at 0x10d55e4b0>for a helpful error message.
I have set my $JAVA_HOME in ~/.bash_profile, the proxy works just fine manually but it just won't run from the python script. It's not an issue with file permission as well since I'm running the script with sudo. I am new to automation and would really appreciate your help here.
from browsermob-proxy-py.
Glad you sorted things out 😀
—
Sent from Mailbox
On Fri, Feb 20, 2015 at 6:14 PM, Chiedo John [email protected]
wrote:
Obvious. I was not supposed to set the "-port" flag.
Reply to this email directly or view it on GitHub:
#30 (comment)
from browsermob-proxy-py.
Hahaha, thanks man. It was definitely a noob move on my part... but maybe change the readme to something like the following? Obviously you can ignore my suggestion though!
browsermob-proxy-py
===================
Python client for the BrowserMob Proxy 2.0 REST API.
How to use with selenium-webdriver
----------------------------------
Manually:
``` python
from browsermobproxy import Server
server = Server("path/to/browsermob-proxy")
server.start()
proxy = server.create_proxy()
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_proxy(proxy.selenium_proxy())
driver = webdriver.Firefox(firefox_profile=profile)
proxy.new_har("google")
driver.get("http://www.google.co.uk")
proxy.har # returns a HAR JSON blob
server.stop()
driver.quit()
for Chrome use
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--proxy-server={0}".format(proxy.proxy))
browser = webdriver.Chrome(chrome_options = chrome_options)
Before Running Tests
Start the browsermob-proxy with the following in your terminal and wait for the proxy to start:
path/to/browsermob-proxy
Running Tests
To run the tests in a CI environment, disable the ones that require human
judgement by using
$ py.test -m "not human" test
If you are going to watch the test, the 'human' ones should display an english
muffin instead of the american flag on the 'pick your version' page. Or at
least it does from Canada.
See also
Note on Patches/Pull Requests
- Fork the project.
- Make your feature addition or bug fix.
- Add tests for it. This is important so I don't break it in a
future version unintentionally. - Send me a pull request. Bonus points for topic branches.
Copyright
Copyright 2011 David Burns
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
from browsermob-proxy-py.
Feel free to help me with docs and the readme by submitting a pull request 😉
—
Sent from Mailbox
On Sat, Feb 21, 2015 at 3:04 PM, Chiedo John [email protected]
wrote:
Hahaha, thanks man. It was definitely a noob move on my part... but maybe change the readme to something like the following? Obviously you can ignore my suggestion though!
browsermob-proxy-py =================== Python client for the BrowserMob Proxy 2.0 REST API. How to use with selenium-webdriver ---------------------------------- Manually: ``` python from browsermobproxy import Server server = Server("path/to/browsermob-proxy") server.start() proxy = server.create_proxy() from selenium import webdriver profile = webdriver.FirefoxProfile() profile.set_proxy(proxy.selenium_proxy()) driver = webdriver.Firefox(firefox_profile=profile) proxy.new_har("google") driver.get("http://www.google.co.uk") proxy.har # returns a HAR JSON blob server.stop() driver.quit()
for Chrome use
chrome_options = webdriver.ChromeOptions() chrome_options.add_argument("--proxy-server={0}".format(proxy.proxy)) browser = webdriver.Chrome(chrome_options = chrome_options)
Before Running Tests
Start the browsermob-proxy with the following in your terminal and wait for the proxy to start:
path/to/browsermob-proxy
Running Tests
To run the tests in a CI environment, disable the ones that require human
judgement by using$ py.test -m "not human" testIf you are going to watch the test, the 'human' ones should display an english
muffin instead of the american flag on the 'pick your version' page. Or at
least it does from Canada.See also
- http://proxy.browsermob.com/
https://github.com/webmetrics/browsermob-proxy
Note on Patches/Pull Requests- Fork the project.
- Make your feature addition or bug fix.
- Add tests for it. This is important so I don't break it in a
future version unintentionally.Send me a pull request. Bonus points for topic branches.
Copyright 2011 David Burns
Copyright
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.--- Reply to this email directly or view it on GitHub: https://github.com/AutomatedTester/browsermob-proxy-py/issues/30#issuecomment-75375393
from browsermob-proxy-py.
Fair enough! :)
from browsermob-proxy-py.
HI I am receiving the very same error while trying to start the server.
import sys
from browsermobproxy import Server
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
server = Server('C:/browsermob-proxy/bin/browsermob-proxy')
server.start()
Kindly please let me know what I am doing wrong
from browsermob-proxy-py.
oh it was a problem of administrative rights on py file
from browsermob-proxy-py.
@chiedojohn, I feel like you got misled a little. You can definitely run browsermob on a different port and still use this library... you just need to pass in an optional secondary argument - the options dict with something like:
server = Server("path/to/browsermob-proxy", options={'port': 9999}.)
https://github.com/AutomatedTester/browsermob-proxy-py/search?utf8=%E2%9C%93&q=8080
from browsermob-proxy-py.
Thanks @aerickson, I actually came to that same conclusion a few weeks ago!
from browsermob-proxy-py.
I have the same issue as on:
- Windows 8.1
- Python 3.6.0 :: Anaconda 4.3.0 (64-bit)
- selenium (3.4.3)
- browsermob-proxy-py (0.8.0)
- browsermob-proxy (2.1.1)
Here's the sample code:
from browsermobproxy import Server
server = Server("C:\\tools\\browsermob-proxy-2.1.1\\bin\\browsermob-proxy")
server.start()
proxy = server.create_proxy()
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_proxy(proxy.selenium_proxy())
driver = webdriver.Firefox(firefox_profile=profile)
proxy.new_har("google")
driver.get("http://www.google.co.uk")
proxy.har # returns a HAR JSON blob
server.stop()
driver.quit()
and here's the output
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\browsermobproxy\client.py", line 34, in __init__
jcontent = json.loads(content)
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\json\__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\json\decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\json\decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "temp.py", line 4, in <module>
proxy = server.create_proxy()
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\browsermobproxy\server.py", line 40, in create_proxy
client = Client(self.url[7:], params)
File "C:\Users\user\AppData\Local\Continuum\Anaconda3\lib\site-packages\browsermobproxy\client.py", line 37, in __init__
"Another server running on this port?\n%s..." % content[:512])
Exception: Could not read Browsermob-Proxy json
Another server running on this port?
java.lang.RuntimeException: java.net.BindException: Address already in use: bind
at org.littleshoot.proxy.impl.DefaultHttpProxyServer.doStart(DefaultHttpProxyServer.java:519)
at org.littleshoot.proxy.impl.DefaultHttpProxyServer.start(DefaultHttpProxyServer.java:463)
at org.littleshoot.proxy.impl.DefaultHttpProxyServer.access$700(DefaultHttpProxyServer.java:70)
at org.littleshoot.proxy.impl.DefaultHttpProxyServer$DefaultHttpProxyServerBootstrap.start(DefaultHttpProxyServer.java:799)
at net.lightbod...
from browsermob-proxy-py.
I'm also hitting this issue with version 2.1.4.
When I do this on the interpreter, I get the below output.
Notice that I only hit the error the first time...
>>> server.start()
>>> proxy = server.create_proxy()
Traceback (most recent call last):
File "/Users/npassosg/.virtualenvs/wan-staging/lib/python3.6/site-packages/browsermobproxy/client.py", line 34, in __init__
jcontent = json.loads(content)
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/npassosg/.virtualenvs/wan-staging/lib/python3.6/site-packages/browsermobproxy/server.py", line 40, in create_proxy
client = Client(self.url[7:], params)
File "/Users/npassosg/.virtualenvs/wan-staging/lib/python3.6/site-packages/browsermobproxy/client.py", line 37, in __init__
"Another server running on this port?\n%s..." % content[:512])
Exception: Could not read Browsermob-Proxy json
Another server running on this port?
java.lang.RuntimeException: java.net.BindException: Address already in use
at org.littleshoot.proxy.impl.DefaultHttpProxyServer.doStart(DefaultHttpProxyServer.java:545)
at org.littleshoot.proxy.impl.DefaultHttpProxyServer.start(DefaultHttpProxyServer.java:489)
at org.littleshoot.proxy.impl.DefaultHttpProxyServer.access$700(DefaultHttpProxyServer.java:69)
at org.littleshoot.proxy.impl.DefaultHttpProxyServer$DefaultHttpProxyServerBootstrap.start(DefaultHttpProxyServer.java:858)
at net.lightbody.bmp.Brows...
>>> proxy = server.create_proxy()
>>>
This is what I see in the proxy process:
Running BrowserMob Proxy using LittleProxy implementation. To revert to the legacy implementation, run the proxy with the command-line option '--use-littleproxy false'.
[INFO 2017-07-05T18:30:37,593 net.lightbody.bmp.proxy.Main] (main) Starting BrowserMob Proxy version 2.1.4
[INFO 2017-07-05T18:30:37,645 org.eclipse.jetty.util.log] (main) jetty-7.x.y-SNAPSHOT
[INFO 2017-07-05T18:30:37,694 org.eclipse.jetty.util.log] (main) started o.e.j.s.ServletContextHandler{/,null}
[INFO 2017-07-05T18:30:37,878 org.eclipse.jetty.util.log] (main) Started [email protected]:8080
[INFO 2017-07-05T18:31:00,667 org.littleshoot.proxy.impl.DefaultHttpProxyServer] (qtp1449605932-16) Starting proxy at address: 0.0.0.0/0.0.0.0:8081
[INFO 2017-07-05T18:31:00,688 org.littleshoot.proxy.impl.DefaultHttpProxyServer] (qtp1449605932-16) Proxy listening with TCP transport
[WARN 2017-07-05T18:31:00,760 net.lightbody.bmp.BrowserMobProxyServer] (qtp1449605932-16) Attempted to stop proxy server, but proxy was never successfully started.
[INFO 2017-07-05T18:31:14,204 org.littleshoot.proxy.impl.DefaultHttpProxyServer] (qtp1449605932-21) Starting proxy at address: 0.0.0.0/0.0.0.0:8082
[INFO 2017-07-05T18:31:14,205 org.littleshoot.proxy.impl.DefaultHttpProxyServer] (qtp1449605932-21) Proxy listening with TCP transport
[INFO 2017-07-05T18:31:14,207 org.littleshoot.proxy.impl.DefaultHttpProxyServer] (qtp1449605932-21) Proxy started at address: /0:0:0:0:0:0:0:0:8082
from browsermob-proxy-py.
It appears that even if you start browsermob-proxy (2.1.1 and 2.1.4) on a different port (e.g. 7070
), it will still spew out a proxy starting at 8081
:
λ bin\browsermob-proxy.bat -port 7070
Running BrowserMob Proxy using LittleProxy implementation. To revert to the legacy implementation, run the proxy with the command-line option '--use-littleproxy false'.
[INFO 2017-07-10T10:27:59,972 net.lightbody.bmp.proxy.Main] (main) Starting BrowserMob Proxy version 2.1.1
[INFO 2017-07-10T10:28:00,027 org.eclipse.jetty.util.log] (main) jetty-7.x.y-SNAPSHOT
[INFO 2017-07-10T10:28:00,403 org.eclipse.jetty.util.log] (main) started o.e.j.s.ServletContextHandler{/,null}
[INFO 2017-07-10T10:28:00,760 org.eclipse.jetty.util.log] (main) Started [email protected]:7070
I have another process running on port 8081
before I executed the curl
request.
λ netstat -ano | find "8081"
TCP 0.0.0.0:8081 0.0.0.0:0 LISTENING 1128
TCP [::]:8081 [::]:0 LISTENING 1128
λ curl -X POST http://localhost:7070/proxy
java.lang.RuntimeException: java.net.BindException: Address already in use: bind
at org.littleshoot.proxy.impl.DefaultHttpProxyServer.doStart(DefaultHttpProxyServer.java:519)
at org.littleshoot.proxy.impl.DefaultHttpProxyServer.start(DefaultHttpProxyServer.java:463)
at org.littleshoot.proxy.impl.DefaultHttpProxyServer.access$700(DefaultHttpProxyServer.java:70)
at org.littleshoot.proxy.impl.DefaultHttpProxyServer$DefaultHttpProxyServerBootstrap.start(DefaultHttpProxyServer.java:799)
...
On the terminal where I launched browsermob-proxy, I get this message:
[INFO 2017-07-10T10:40:53,245 org.littleshoot.proxy.impl.DefaultHttpProxyServer] (qtp664186542-15) Starting proxy at address: 0.0.0.0/0.0.0.0:8081
[INFO 2017-07-10T10:40:53,278 org.littleshoot.proxy.impl.DefaultHttpProxyServer] (qtp664186542-15) Proxy listening with TCP transport
[WARN 2017-07-10T10:40:53,611 net.lightbody.bmp.BrowserMobProxyServer] (qtp664186542-15) Attempted to stop proxy server, but proxy was never successfully started.
from browsermob-proxy-py.
my problem was with jre not installed.
sudo apt-get install default-jre solved my problem.
from browsermob-proxy-py.
Related Issues (20)
- how to clear old page's network
- How to use with selenium-webdriver for IE?
- Getting error 'The Browsermob-Proxy server process failed to start' HOT 2
- Hi bro, I am new to this python and selenium thing. I am getting this error when running this code.
- Unable to clear blacklist
- Please push latest updates to PyPi HOT 6
- "No JSON object could be decoded" HOT 3
- using pip to install browsermob-proxy encounter exceptions
- Trusting all Servers and bypassing Basic Authentication HOT 2
- Modifying Connection header HOT 1
- profile.set_proxy(proxy.selenium_proxy()) HOT 5
- "pip install" installs browsermob-proxy 0.8.0, not 2.0 or 2.1.5 HOT 4
- Getting the error "browsermobproxy.exceptions.ProxyServerError" HOT 3
- cannot configure options for start server
- Another server running on this port or An existing connection was forcibly closed by the remote host
- This method has been deprecated. Please pass in the proxy object to the Driver Object HOT 2
- How to use browsermob with python-selenium behind a corporate proxy? HOT 2
- Cannot install browsermobproxy with pip nor python -m pip HOT 1
- Unable to locate dependent libraries when absolute path is not given to the Server() instance HOT 2
- 404 returned when call basic_authentication method. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from browsermob-proxy-py.