I'm getting a broken pipe error with gae/python, and none of the solutions I can find seem to apply to my case. (For example, the question below is similar, but it hinges on the use of submit vs button which is not my issue).
Google App Engine & jQuery Ajax causes a Broken Pipe error
Here's my javascript:
var testVar = [1,2]
function testFun() {
jQuery.post("http://localhost:8084",testVar.toString(), function()
{
console.log( "post ok" );
}
)
document.write(testVar)
}
Here's the HTML:
<!doctype html>
<html>
<head>
<title>Experiment</title>
<meta charset="utf-8" />
<style type="text/css"> </style>
<script type="text/javascript" src="lib/jquery/jquery-1.4.2.js"></script>
<script src="js/posttestjs.js"></script>
</head>
<body>
<input id = "start_button" type="button" onclick= "testFun()" value="begin">
</body>
</html>
And here's my python:
from google.appengine.ext import db
import webapp2
import logging
class data(webapp2.RequestHandler):
def post(self):
logging.info('CHECK1')
self.response.out.write("""<html><body> CHECK2 </body></html>""")
app = webapp2.WSGIApplication([('/', data)] , debug = True)
The error I get is this:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock
self.process_request(request, client_address)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 310, in process_request
self.finish_request(request, client_address)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine- default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 2630, in __init__
BaseHTTPServer.BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 640, in __init__
self.finish()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 693, in finish
self.wfile.flush()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
Last, here's my .yaml file:
application: posttestjs
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /static
static_dir: static
- url: /.*
script: posttestjs.app
I see CHECK1 in the log, so I think that the post is received OK, but the response doesn't work.
In case it's relevant: I'm using firefox, and python 2.7.3. Thanks!