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

Can't GET or POST request for custom ports with URL #1528

Closed
XCanG opened this issue Jan 5, 2017 · 4 comments
Closed

Can't GET or POST request for custom ports with URL #1528

XCanG opened this issue Jan 5, 2017 · 4 comments
Labels

Comments

@XCanG
Copy link

XCanG commented Jan 5, 2017

I use server to recieve some requests and then generate new ones and send it on another local server with custom port 410, but when I make async with session.get('http://127.0.0.1:410/someurl') as resp: (someurl for example here) I get error:

Error handling request
Traceback (most recent call last):
  File "C:\Python\Python36\lib\site-packages\aiohttp\client.py", line 181, in _request
    yield from resp.start(conn, read_until_eof)
  File "C:\Python\Python36\lib\site-packages\aiohttp\client_reqrep.py", line 614, in start
    message = yield from httpstream.read()
  File "C:\Python\Python36\lib\site-packages\aiohttp\streams.py", line 640, in read
    result = yield from super().read()
  File "C:\Python\Python36\lib\site-packages\aiohttp\streams.py", line 470, in read
    raise self._exception
aiohttp.errors.ServerDisconnectedError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Python\Python36\lib\site-packages\aiohttp\web_server.py", line 61, in handle_request
    resp = yield from self._handler(request)
  File "C:\Python\Python36\lib\site-packages\aiohttp\web.py", line 249, in _handle
    resp = yield from handler(request)
  File "run.py", line 24, in handler_get
    async with session.get('http://127.0.0.1:410/someurl') as resp:
  File "C:\Python\Python36\lib\site-packages\aiohttp\client.py", line 540, in __aenter__
    self._resp = yield from self._coro
  File "C:\Python\Python36\lib\site-packages\aiohttp\client.py", line 188, in _request
    raise aiohttp.ClientResponseError() from exc
aiohttp.errors.ClientResponseError

But at that time I can request to http://127.0.0.1:410/ and normally get content.

Example code:

async with aiohttp.ClientSession() as session:
    async with session.get('http://127.0.0.1:410/someurl') as resp:
        print(resp.status)
        print(await resp.text())

I coding on Windows 10, Python ver. 3.6.0

@fafhrd91
Copy link
Member

fafhrd91 commented Feb 1, 2017

i am not sure it is aiohttp problem, seems your http://127.0.0.1:410/someurl drops connection.

@XCanG
Copy link
Author

XCanG commented Feb 1, 2017

@fafhrd91 no, it open normally in browser and get can open root url.

@fafhrd91
Copy link
Member

fafhrd91 commented Feb 1, 2017

i did quick test:

test_1528.py:

#!/usr/bin/env python3
import asyncio
from aiohttp.web import Application, Response, HTTPOk, run_app


async def index(request):
    return Response(status=200, text='test')

async def init(loop):
    app = Application()
    app.router.add_get('/', index)
    return app


loop = asyncio.get_event_loop()
app = loop.run_until_complete(init(loop))
run_app(app, port=410)

test_1528_2.py:

#!/usr/bin/env python3
import asyncio
import aiohttp
from aiohttp.web import Application, Response, HTTPOk, run_app


async def index(request):
    async with aiohttp.ClientSession() as session:
        async with session.get('http://127.0.0.1:410/') as resp:
            print(resp.status)
            print(await resp.text())
            return Response(status=200, text='test')

async def init(loop):
    app = Application()
    app.router.add_get('/', index)
    return app


loop = asyncio.get_event_loop()
app = loop.run_until_complete(init(loop))
run_app(app, port=8080)

got:

>> curl -v http://127.0.0.1:8080/
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.51.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/plain; charset=utf-8
< Content-Length: 4
< Date: Wed, 01 Feb 2017 19:32:57 GMT
< Server: Python/3.5 aiohttp/1.3.0a0

@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

2 participants