XX-net/XX-Net · warning
gae send response fail. %r
Error message
gae send response fail. %r
What it means
While writing an HTTP response back to the local client browser over the (possibly TLS) socket, an ssl.SSLError occurred. The connection to the browser is abandoned; the browser will typically show a connection reset / empty response.
Source
Thrown at code/default/gae_proxy/local/gae_handler.py:209
def send_response(wfile, status=404, headers={}, body=b''):
body = utils.to_bytes(body)
headers = dict((k.title(), v) for k, v in list(headers.items()))
if b'Transfer-Encoding' in headers:
del headers[b'Transfer-Encoding']
if b'Content-Length' not in headers:
headers[b'Content-Length'] = len(body)
if b'Connection' not in headers:
headers[b'Connection'] = b'close'
try:
wfile.write(b"HTTP/1.1 %d\r\n" % status)
for key, value in list(headers.items()):
send_header(wfile, key, value)
wfile.write(b"\r\n")
wfile.write(body)
except ssl.SSLError as e:
xlog.warn("gae send response fail. %r", e)
return
except Exception as e:
if sys.version_info[0] == 3 and (
isinstance(e, ConnectionError) or
isinstance(e, ConnectionResetError) or
isinstance(e, BrokenPipeError)
):
xlog.warn("gae send response fail. %r", e)
else:
xlog.exception("send response fail %r", e)
def return_fail_message(wfile):
html = generate_message_html(
'504 GAEProxy Proxy Time out', '连接超时,先休息一会再来!')
send_response(wfile, 504, body=utils.to_bytes(html))
return
View on GitHub (pinned to cfa5bc17b6)
Solutions
- Usually benign (client-side disconnect); ignore unless frequent
- Check the local certificate setup (import the local CA in the browser) if it happens consistently
- Disable interfering middleboxes/AV TLS scanning for localhost connections
- Reproduce with curl -k against the local proxy port to isolate browser-specific TLS issues
Defensive patterns
Strategy: try-catch
Try / catch
except ssl.SSLError:
pass # client-side TLS abort; nothing to recover server-side Prevention
- Import the proxy CA cert into the browser to avoid mid-stream TLS failures
- Don't run TLS-inspecting middleboxes on loopback traffic
When it happens
Trigger: send_response writing status/headers/body raises ssl.SSLError: browser closed the TLS connection early, TLS handshake/renegotiation failure, or truncation when writing body.
Common situations: User cancels page load, browser tab closed mid-response, MITM proxy interfering with local TLS, browser rejecting the self-signed cert mid-stream.
Related errors
AI-assisted analysis of XX-net/XX-Net@cfa5bc17b6 (2026-08-27).
Data as JSON: /api/errors/046b6d72aae60929.
Report an issue: GitHub.