Skip to content
This repository has been archived by the owner. It is now read-only.

phantomjs with selenium 2.38.1 fails with BadStatusLine exception #6690

Closed
lukeis opened this issue Mar 4, 2016 · 12 comments
Closed

phantomjs with selenium 2.38.1 fails with BadStatusLine exception #6690

lukeis opened this issue Mar 4, 2016 · 12 comments

Comments

@lukeis
Copy link
Member

@lukeis lukeis commented Mar 4, 2016

Originally reported on Google Code with ID 6690

The following snippet reproduces the error:


>>> from selenium import webdriver
>>> p = webdriver.PhantomJS()
>>> p.get("http://www.google.com")
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py",
line 176, in get
    self.execute(Command.GET, {'url': url})
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py",
line 162, in execute
    response = self.command_executor.execute(driver_command, params)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/remote_connection.py",
line 350, in execute
    return self._request(url, method=command_info[0], data=data)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/remote_connection.py",
line 382, in _request
    resp = self._conn.getresponse()
  File "/usr/lib/python2.7/httplib.py", line 1045, in getresponse
    response.begin()
  File "/usr/lib/python2.7/httplib.py", line 409, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python2.7/httplib.py", line 373, in _read_status
    raise BadStatusLine(line)
BadStatusLine: ''

Selenium version: 2.38.1
OS: OS X 10.9
Browser: PhantomJS
Browser version: 1.9.2


A bisect from 2.37 to 2.38.1 shows https://github.com/SeleniumHQ/selenium/commit/93dc1284534330866238d85521e40dd4de435def
to be the first commit where the behaviour was introduced.

Reported by ali@indydevs.org on 2013-12-09 00:53:28

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 4, 2016

I accidentally pasted the snippet in the description from Ubuntu 13.04 with Selenium
2.38.1 and PhantomJS 1.9.2. The behaviour however, is identical on OS X.

Reported by ali@indydevs.org on 2013-12-09 01:18:42

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 4, 2016

I've also experienced this issue. From that commit onwards, Selenium uses Keep-Alive
in its WebDriver connections, and makes the assumption that the WebDriver implementation
it's connecting to supports it. However, PhantomJS doesn't have Keep-Alive support
enabled by default, and GhostDriver (PhantomJS's WebDriver implementation) doesn't
have the option to enable it at all.

There seem to be two resolutions to the issue: either
(a) make Selenium restart the connection when Keep-Alive is sent to the WebDriver implementation
but not received, or
(b) add a command line option to PhantomJS that enables Keep-Alive in GhostDriver (by
passing {'keepAlive': true} as the second arg to server.listen in main.js)

The second seems preferable, since as far as I can see, support for persistent connections
is supposed to be part of the HTTP 1.1 specification.

Reported by george.caley@bigcommerce.com on 2013-12-10 01:21:09

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 4, 2016

I agree that the second option is preferable - however, it might take some time before
a version of PhantomJS which supports keep alive in GhostDriver makes it way around
- in which case option 1 might be a sufficient short term solution 

Reported by ali@indydevs.org on 2013-12-10 02:25:17

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 4, 2016

There isn't a lot of code involved in implementing option 2 (I'm writing it up now),
but yes, it's anyone's guess how long the changes would take to be accepted ;)

Reported by george.caley@bigcommerce.com on 2013-12-10 02:41:52

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 4, 2016

I submitted a pull request to GhostDriver (https://github.com/detro/ghostdriver/pull/290).
I assume I would need to first get that merged into the GhostDriver repo, wait for
the codebase to be declared stable, and then added to the PhantomJS repo, after which
I can submit part 2 which is the changes to PhantomJS... all for about 20 lines of
code! :(

Reported by george.caley@bigcommerce.com on 2013-12-10 03:24:23

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 4, 2016

FYI, seeing this with:

Selenium 2.38.3
PhantomJS 1.9.2 (installed from tar NOT apt-get repo)
Django 1.5.5
Ubuntu 13.10

Reported by maestrofjp on 2013-12-10 09:28:11

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 4, 2016

Also seeing this on ubuntu 12.04.3 LTS using Selenium 2.38.3 with webdriverplus 0.1.5
python 2.7.3. The browser is phantomjs 1.9.1.

Works fine with Selenium 2.37.2

Reported by rbhojani on 2013-12-10 23:52:02

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 4, 2016

I couldn't find a consistent way to detect whether a webdriver server supports keep
alive or not. I've sent a pull request (https://github.com/SeleniumHQ/selenium/pull/150
) with a retry mechanism. This might also help safeguard in cases where the connection
has been idle for long enough for the remote server to sever the connection and the
client wants to continue using the driver.

Reported by ali@indydevs.org on 2013-12-11 01:08:30

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 4, 2016

use 2.38.4

Reported by luke.semerau on 2013-12-12 22:08:07

  • Status changed: Fixed
@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 4, 2016

I have the same issue. 

Mac OSX 10.9.5
Selenium 2.38.4 and Selenium 2.43.0
PhantomJS 1.9.7

Reported by ignacio@ipmonline.es on 2014-09-26 08:16:27

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 4, 2016

This issue has apparently been fixed but I have this issue using selenium 2.38.4 (from
comment #10) and 2.37.2 (from comment #8).  Would someone point out which version combination
of Selenium and PhantomJS resolves this issue.  I'm running on Linux.

selenium 2.44 and phantomJS 1.9 doesn't work
selenium 2.38.4 and phantomJS 1.9/1.8 doesn't work
selenium 2.37.2 and phantomJS 1.9/1.8 doesn't work

Reported by airvic.munoz on 2015-01-29 18:36:27

@lukeis
Copy link
Member Author

@lukeis lukeis commented Mar 4, 2016

Reported by luke.semerau on 2015-09-17 18:18:19

  • Labels added: Restrict-AddIssueComment-Commit
@lukeis lukeis closed this Mar 4, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.