Instapy: selenium.common.exceptions.WebDriverException: Message: chrome not reachable

Created on 25 Jun 2017  ·  19Comments  ·  Source: timgrossmann/InstaPy

New bug, stopped my script twice now. I am running it on an ubuntu server. Script crashed after roughly 400 (for the first time) and 450 (for the second time) likes. Please find below the traceback. Cheers
Fabian

Traceback (most recent call last):
  File "LikeSCript.py", line 16, in <module>
    .like_by_tags([<My Tags>], amount=300, media='Photo')\
  File "/root/InstaPy/instapy/instapy.py", line 386, in like_by_tags
    liked = like_image(self.browser)
  File "/root/InstaPy/instapy/like_util.py", line 279, in like_image
    browser.execute_script("document.getElementsByClassName('" + like_elem[0].get_attribute("class") + "')[0].click()")
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webelement.py", line 111, in get_attribute
    resp = self._execute(Command.GET_ELEMENT_ATTRIBUTE, {'name': name})
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webelement.py", line 461, in _execute
    return self._parent.execute(command, params)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: chrome not reachable
  (Session info: chrome=59.0.3071.109)
  (Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.4.0-81-generic x86_64)
bug help wanted

Most helpful comment

I've had this issue with Selenium itself. The problem was that I didn't have enough memory on the server, so Chrome just crashed.

All 19 comments

@FBosler Could you give some stats about how and where you're running it?

Sure. It just crashed for the third time in a row, this time at the first tag.

excludePpl = ['list of my friends']

InstaPy(username='myName', password='myPass!', nogui=True)\
  .login()\
  .set_dont_include(excludePpl)\
  .set_upper_follower_count(limit = 500)\
  .set_do_follow(enabled=True, percentage=10, times=1)\
  .set_do_comment(True, percentage=15)\
  .set_comments(['Fantastic!', 'Awesome!', 'Brilliant!', 'Cool!', 'I love it', u'⭐']) \
  .set_use_clarifai(enabled=True, secret='mySecret', proj_id='myProjectId')\
  .clarifai_check_img_for(['nsfw'])\
  .like_by_tags(['myTags'], amount=300, media='Photo')\
  .unfollow_users(amount=75)\
  .end()

I run it by calling (manually, i.e. no cronjob):
my script with: nohup python3.5 LikeScript.py &

I run it on:
DigitalOcean Droplet with: 1 GB Memory / 30 GB Disk / Ubuntu 16.04.2 x64

@FBosler Do a ps aux on your server... There are probably some zombie chromes running there...

Simply turn it off and on on DO or do a reboot

Good idea. However, I already did that. There were no zombies :) which is good I guess, cuz zombies are bad.

Can try the reboot later. Have you encountered the problem before?

@FBosler Yes, I find it really interesting, that, given you set it up with the "How_to", people encounter so many problems when my script runs without any incidents for 3 months now 🤔

For me it was simply reboot

Error persists, even after reboot. Really no idea whats going on ... :(

[17/300]
Traceback (most recent call last):
  File "LikeSCript.py", line 17, in <module>
    .like_by_tags(['skiing','surfing','winter'], amount=300, media='Photo')\
  File "/root/InstaPy/instapy/instapy.py", line 383, in like_by_tags
    self.username, self.like_by_followers_upper_limit, self.like_by_followers_lower_limit)
  File "/root/InstaPy/instapy/like_util.py", line 166, in check_link
    browser.get(link)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 248, in get
    self.execute(Command.GET, {'url': url})
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: chrome not reachable
  (Session info: chrome=59.0.3071.109)
  (Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.4.0-81-generic x86_64)

@FBosler Ahh, this could also be due to the wrong version of the chrome driver you put into /assets.

Try to both update Chrome on that machine and remove the chrome driver and download it again

I did follow the "how to" step by step though. I mean, you really made it foolproof with the script and all.

How would I go about updating chrome on ubuntu?

Tonight everything worked as expected. I didn't update anything though. Very strange.

@FBosler Well, if the installation worked, you could just do apt-get update and apt-get upgrade

This should upgrade all dependencies including the chrome browser.
Also make sure to get the latest chrome driver.

If that does not work, please try with a new droplet and follow the instructions one by one.

I have random crashes too, also run on DigitalOcean Droplet with: 1 GB Memory / 30 GB Disk / Ubuntu 16.04.2 x64

  File "grow.py", line 53, in <module>
    session.like_by_tags(TAGS, amount=12)
  File "/home/rat/InstaPy/instapy/instapy.py", line 386, in like_by_tags
    liked = like_image(self.browser)
  File "/home/rat/InstaPy/instapy/like_util.py", line 275, in like_image
    like_elem = browser.find_elements_by_xpath("//a[@role = 'button']/span[text()='Like']")
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 305, in find_elements_by_xpath
    return self.find_elements(by=By.XPATH, value=xpath)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 778, in find_elements
    'value': value})['value']
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: session deleted because of page crash
from unknown error: cannot determine loading status
from tab crashed
  (Session info: chrome=59.0.3071.115)
  (Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 4.4.0-81-generic x86_64)

@velocityzen This can be due to zombie instances of chrome still running in the background...

You can e.g. add a reboot to the end of your script to make sure that you always have a clean droplet for running the script

@timgrossmann Thank you! After reboot it goes smooth. I'll try to add killall -9 chrome after the "show".

I don't think we should close this. For me the error popped up again last night. I don't know the reason yet, but it's not always solved with a reboot.

I had this error from a couple days ago. Doing apt-get update and apt-get upgrade, and then git pull to update InstaPy fixed everything for me.

I am also running on Digital Ocean and used the How to steps.

@IPYWorld : same here, I went through the same steps and It did work fine two or three times until last night when the same bug occured again. As I said, I would leave this issue open for information gathering.

Bug still happening ... weird:

[62/72]
Traceback (most recent call last):
File "LikeSCript.py", line 17, in
.like_by_tags(['mytags'], amount=300, media='Photo')\
File "/root/InstaPy/instapy/instapy.py", line 383, in like_by_tags
self.username, self.like_by_followers_upper_limit, self.like_by_followers_lower_limit)
File "/root/InstaPy/instapy/like_util.py", line 170, in check_link
post_page = browser.execute_script("return window._sharedData.entry_data.PostPage")
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 465, in execute_script
'args': converted_args})['value']
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: chrome not reachable
(Session info: chrome=59.0.3071.115)
(Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 4.4.0-81-generic x86_64)

@timgrossmann sorry to bother you with this, but since I am fairly new to servers I figured it wouldn't hurt to ask. What do I have to add to my python script to reboot the server? Can I just add a simple reboot at the end of the script?

@FBosler

from subprocess import call
call(["reboot"])

should do it.

I've had this issue with Selenium itself. The problem was that I didn't have enough memory on the server, so Chrome just crashed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rahulkapoor90 picture rahulkapoor90  ·  3Comments

harrypython picture harrypython  ·  3Comments

ingorichter picture ingorichter  ·  3Comments

ghost picture ghost  ·  3Comments

tibor picture tibor  ·  3Comments