chazkii / chromewhip

Scriptable Google Chrome™ as a HTTP service + asyncio driver
MIT License
118 stars 16 forks source link

Example from Readme does not work #5

Closed ghost closed 7 years ago

ghost commented 7 years ago

I am trying to launch code from your readme. Docker container was started using the command: run --init -it --rm --shm-size=1024m -p 127.0.0.1:8080:8080 --cap-add=SYS_ADMIN chuckus/chromewhip

Error in line: loop.run_until_complete(c.connect())

I am using Native Docker for Windows, probably it can be a problem

Traceback:

File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\asyncio\base_events.py", line 467, in run_until_complete return future.result() File "F:\VirtualEnv\proj\lib\site-packages\chromewhip\chrome.py", line 315, in connect await asyncio.wait_for(self.attempt_tab_fetch(), timeout=5) File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\asyncio\tasks.py", line 358, in wait_for return fut.result() File "F:\VirtualEnv\proj\lib\site-packages\chromewhip\chrome.py", line 321, in attempt_tab_fetch async with session.get(self._url + '/json') as resp: File "F:\VirtualEnv\proj\lib\site-packages\aiohttp\client.py", line 637, in aenter self._resp = yield from self._coro File "F:\VirtualEnv\proj\lib\site-packages\aiohttp\client.py", line 241, in _request yield from resp.start(conn, read_until_eof) File "F:\VirtualEnv\proj\lib\site-packages\aiohttp\client_reqrep.py", line 559, in start (message, payload) = yield from self._protocol.read() File "F:\VirtualEnv\proj\lib\site-packages\aiohttp\streams.py", line 509, in read yield from self._waiter aiohttp.client_exceptions.ServerDisconnectedError: None

ghost commented 7 years ago

Docker runs with port

127.0.0.1:8080:8080

In readme example: HOST = '127.0.0.1' PORT = 9222

Can you explain what port should I use in my program?

chazkii commented 7 years ago

Just to clarify, are you trying to run chromewhip as a service deploying as a Docker container, or you want to run the low-level driver that the chromewhip service uses?

As you are using that code snippet from the README, I am assuming the low-level driver. The low-level driver doesn't require docker at all, just a Python 3.6 environment (though one may want to run their environment in a docker container)

It looks like you are running a Python 3.6 environment on Windows, which isn't really supported and I am unable to test on my end.

Despite that, the README is unclear on how to run that code, which I will fix very soon, probably over the weekend. Just skimming over it, AFAIR it assumes that you are running a Google Chrome process with --remote-debugging-address=127.0.0.1 and --remote-debugging-port=9222 flags.

ghost commented 7 years ago

Thanks for your answer. I thought that your lib relies on some code running in docker container. So I have to start docker container, then your lib connects to port 8080 and uses Chrome builtin in the container.

Eventually, I just missed starting Chrome with --remote-debugging-port=9222 flag on my system. It will be nice if you make documentation more verbose.