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

when I use the proxy option for client get method, I got 'Constructor parameter must be string' #3408

Closed
xgnit opened this issue Nov 25, 2018 · 4 comments

Comments

@xgnit
Copy link

xgnit commented Nov 25, 2018

Code ist simple

async def run(self, proxy):
    proxy_for_requests = {'https': proxy}
    try:
        async with aiohttp.ClientSession() as session:
            async with session.get(url='https://www.google.com', proxy=proxy_for_requests,
                                                timeout=5, headers=self.get_headers()) as resp:
                return proxy
    except Exception as e:
        print(str(e))
        return None

Expected:
When it's a timeout problem, it returns None.

Actual:
this function always raises the error: "Constructor parameter should be str". I removed the option timeout and headers, but it still the same case. Only when I left the only option url, it can run correctly.
It seems the options for this session.get are not available.

my aiohttp is 3.4.4 and my OS is windows 10.

@aio-libs-bot
Copy link

GitMate.io thinks the contributor most likely able to help you is @asvetlov.

Possibly related issues are #1455 (How to use Proxy?), #1167 (Client session method that accepts http verb as a parameter), #1293 (Use timeout in client), #3385 (Disable body parameter in HTTPException constructor), and #499 (Url GET parameters are lost when redirecting).

@xgnit
Copy link
Author

xgnit commented Nov 25, 2018

I found the error, I passed an argument format as the python requests, so basically I passed a dictionary object. When I changed it to string, everything worked fine. But it seems it does not work work with https. I hope you guys can make a update for this.

@xgnit xgnit closed this as completed Nov 25, 2018
@xgnit
Copy link
Author

xgnit commented Nov 25, 2018

So maybe raise an error to say that the proxy argument format is not correct rather than let the yarl URL do the job?

@lock
Copy link

lock bot commented Nov 25, 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 Nov 25, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Nov 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants