BadStatusLine when run dev_appserver

192 views
Skip to first unread message

Amaranth F

unread,
Feb 27, 2014, 1:01:21 PM2/27/14
to google-a...@googlegroups.com
My helloworld.py is like this:
def main(environ,start_response):
   response_body = 'The request method was %s' % environ['REQUEST_METHOD']
   status = '200 OK'
   response_headers = [('Content-Type', 'text/plain'),
                       ('Content-Length', str(len(response_body)))]
   start_response(status, response_headers)
   return [response_body]

then I ran "python dev_appserver.py proj/test" succeeded.
but I got a BadStatusLine exception when I goto http://localhost:8080.

Did anyone know how to solve this?

BadStatusLine: ''
Traceback (most recent call last):
  File "F:\Program\google_appengine\lib\cherrypy\cherrypy\wsgiserver\wsgiserver2
.py", line 1302, in communicate
    req.respond()
  File "F:\Program\google_appengine\lib\cherrypy\cherrypy\wsgiserver\wsgiserver2
.py", line 831, in respond
    self.server.gateway(self).respond()
  File "F:\Program\google_appengine\lib\cherrypy\cherrypy\wsgiserver\wsgiserver2
.py", line 2115, in respond
    response = self.req.server.wsgi_app(self.env, self.start_response)
  File "F:\Program\google_appengine\google\appengine\tools\devappserver2\wsgi_se
rver.py", line 269, in __call__
    return app(environ, start_response)
  File "F:\Program\google_appengine\google\appengine\tools\devappserver2\request
_rewriter.py", line 311, in _rewriter_middleware
    response_body = iter(application(environ, wrapped_start_response))
  File "F:\Program\google_appengine\google\appengine\tools\devappserver2\python\
request_handler.py", line 148, in __call__
    self._flush_logs(response.get('logs', []))
  File "F:\Program\google_appengine\google\appengine\tools\devappserver2\python\
request_handler.py", line 284, in _flush_logs
    apiproxy_stub_map.MakeSyncCall('logservice', 'Flush', request, response)
  File "F:\Program\google_appengine\google\appengine\api\apiproxy_stub_map.py",
line 94, in MakeSyncCall
    return stubmap.MakeSyncCall(service, call, request, response)
  File "F:\Program\google_appengine\google\appengine\api\apiproxy_stub_map.py",
line 328, in MakeSyncCall
    rpc.CheckSuccess()
  File "F:\Program\google_appengine\google\appengine\api\apiproxy_rpc.py", line
156, in _WaitImpl
    self.request, self.response)
  File "F:\Program\google_appengine\google\appengine\ext\remote_api\remote_api_s
tub.py", line 200, in MakeSyncCall
    self._MakeRealSyncCall(service, call, request, response)
  File "F:\Program\google_appengine\google\appengine\ext\remote_api\remote_api_s
tub.py", line 226, in _MakeRealSyncCall
    encoded_response = self._server.Send(self._path, encoded_request)
  File "F:\Program\google_appengine\google\appengine\tools\appengine_rpc.py", li
ne 409, in Send
    f = self.opener.open(req)
  File "e:\software\python27\lib\urllib2.py", line 404, in open
    response = self._open(req, data)
  File "e:\software\python27\lib\urllib2.py", line 422, in _open
    '_open', req)
  File "e:\software\python27\lib\urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "e:\software\python27\lib\urllib2.py", line 1214, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "e:\software\python27\lib\urllib2.py", line 1187, in do_open
    r = h.getresponse(buffering=True)
  File "e:\software\python27\lib\httplib.py", line 1045, in getresponse
    response.begin()
  File "e:\software\python27\lib\httplib.py", line 409, in begin
    version, status, reason = self._read_status()
  File "e:\software\python27\lib\httplib.py", line 373, in _read_status
    raise BadStatusLine(line)

Vinny P

unread,
Mar 16, 2014, 10:59:15 AM3/16/14
to google-a...@googlegroups.com
On Thu, Feb 27, 2014 at 12:01 PM, Amaranth F <falli...@gmail.com> wrote:
My helloworld.py is like this:
   response_headers = [('Content-Type', 'text/plain'),
                       ('Content-Length', str(len(response_body)))]
   start_response(status, response_headers)
   return [response_body]

then I ran "python dev_appserver.py proj/test" succeeded.
but I got a BadStatusLine exception when I goto http://localhost:8080.

Did anyone know how to solve this?

BadStatusLine: ''
Traceback (most recent call last):
  File "e:\software\python27\lib\httplib.py", line 373, in _read_status
    raise BadStatusLine(line)




The BadStatusLine error originates from httplib.py, and the source code for httplib ( http://hg.python.org/cpython/file/2.7/Lib/httplib.py scroll down to line 373) indicates this error occurs when the server closes the connection prematurely, or doesn't receive a valid response. 

There may be an issue with your local dev environment. Can you try running the official helloword example application at https://github.com/GoogleCloudPlatform/appengine-helloworld-python and see if it works for you?
 
 
-----------------
-Vinny P
Technology & Media Advisor
Chicago, IL

App Engine Code Samples: http://www.learntogoogleit.com

Krishna Chaitanya Kornepati

unread,
Aug 8, 2015, 5:25:51 PM8/8/15
to Google App Engine
I'm getting error even on official example. please help

Patrice (Cloud Platform Support)

unread,
Aug 10, 2015, 12:13:54 PM8/10/15
to Google App Engine
Hi,

I just ran some tests, and I was on a Linux machine and couldn't reproduce the issue, whether I was using dev_appserver.py or gcloud.

Did you try running "gcloud preview app run" instead of dev_appserver.py? Does it give the same error?

Also, what version of the SDK are you using, and what OS are you on? I'm trying to setup a windows VM to try and run this with the Windows SDK to see if this could be the issue.

Cheers!
Reply all
Reply to author
Forward
0 new messages