Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NotImplementedError from aiohttp/server.py L268 #1537

Closed
achimnol opened this issue Jan 10, 2017 · 14 comments
Closed

NotImplementedError from aiohttp/server.py L268 #1537

achimnol opened this issue Jan 10, 2017 · 14 comments
Labels

Comments

@achimnol
Copy link
Member

Long story short

In my aiohttp-based API server logs, I could see the below exception very rarely (only once so far).

2017-01-10 05:45:22 ERROR aiohttp.server Error handling request
Traceback (most recent call last):
  File "/home/sorna/venv/lib/python3.6/site-packages/aiohttp/server.py", line 268, in start
    self.transport.write_eof()
  File "/home/sorna/.pyenv/versions/3.6.0/lib/python3.6/asyncio/transports.py", line 117, in write_eof
    raise NotImplementedError
NotImplementedError

The line 117 in asyncio/transports.py is part of an abstract class WriteTransport.
I think this suggests that the exception might be a bug.

Steps to reproduce

I don't know how to reproduce this exactly, but this happened during repeated API query authentication tests where the client was a NodeJS program using "fetch" API via a https (SSL) connection.

Your environment

Server: Python 3.6.0 + aiohttp 1.2
Client: Atom 1.12.9 (a custom plugin that uses fetch() API)

@nodermann2
Copy link

nodermann2 commented Jan 10, 2017

Without the code, the likelihood of someone will help you is zero.

@achimnol
Copy link
Member Author

achimnol commented Jan 10, 2017

The server-side code is at https://github.com/lablup/sorna-manager. It basically uses aiohttp.web and a SSL certificate -- you could check the initialization/shutdown process here. This exception happens in purely aiohttp, not in the request handlers I have written (between finish of my handlers and beginning of my handlers). Though, the tested request handler is here.
The client-side code is at https://github.com/lablup/sorna-code-runner/blob/1509d69/lib/sorna-code-runner.coffee#L124-L154.

The problem is, installing/configuring them is a non-trivial work.
I just have no time to write complete docs for that right now... :(

@fafhrd91
Copy link
Member

seems like asyncio bug

@fafhrd91
Copy link
Member

@achimnol could you consistently reproduce this bug?

@fafhrd91
Copy link
Member

@achimnol do you use uvloop?

@1st1 seems related to uvloop

@achimnol
Copy link
Member Author

@fafhrd91 Yes, I'm using uvloop. I could not reilably reproduce this bug though.

@1st1
Copy link
Contributor

1st1 commented Jan 27, 2017

Do you see it without uvloop?

@achimnol
Copy link
Member Author

@1st1 I haven't tested this without uvloop. Further, I have not seen this bug after reporting this issue even using uvloop.

@fafhrd91
Copy link
Member

@achimnol please re-open if you get more information

@p-hash
Copy link

p-hash commented Feb 27, 2017

@fafhrd91 I'm experiencing same issue with python 3.4

Error handling request
Traceback (most recent call last):
  File "/home/paul/mpb-v2/env/lib/python3.4/site-packages/aiohttp/server.py", line 282, in start
    self.transport.write_eof()
  File "/usr/lib64/python3.4/asyncio/transports.py", line 111, in write_eof
    raise NotImplementedError
NotImplementedError

Code:

import asyncio
import ssl
from aiohttp import web
import config

def run():
    loop = asyncio.get_event_loop()
    app = web.Application()

    if config.SSL_CERT:
        context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
        context.load_cert_chain(config.SSL_CERT, config.SSL_PKEY)
    else:
        context = None

    return web.run_app(
        app,
        host=config.LISTEN,
        port=config.PORT,
        ssl_context=context
    )

if __name__ == '__main__':
    run()

I use Python 3.4.3 (venv) and aiohttp 1.3.3.

UPD: some request cause the exception, others are not. I tried to find a req that reproduces the problem, but havent found yet. Setting debug=True in web.Application() isnt helpful.

@p-hash
Copy link

p-hash commented Feb 27, 2017

Issue reproduces every time request comes from Telegram when using webhook to get bot updates, but i cant recreate the request using curl. Any request from curl handles successfully with 404 response.

@freekvw
Copy link

freekvw commented Feb 28, 2017

I can reliably reproduce this when uploading a file (of more than about 50 KiB) through an HTTPS connection, and responding to it without reading the full request, e.g. like this:

from aiohttp import web
import ssl

async def handle(request):
	text = """<html><body>
<form action="/upload" method="post" accept-charset="utf-8"
      enctype="multipart/form-data">
    <input name="file" type="file" value=""/><br />
    <input type="submit" value="submit"/>
</form></body></html>"""
	return web.Response(text=text, content_type='text/html')

async def handleUpload(request):
	return web.json_response({})

app = web.Application()
app.router.add_get('/', handle)
app.router.add_post('/upload', handleUpload)

context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
context.load_cert_chain(certfile="cert.pem")

web.run_app(app, ssl_context=context)

@p-hash
Copy link

p-hash commented Mar 8, 2017

@freekvw i've reopened the issue in #1703

@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants