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

websockets #194

Closed
vlad-dragos opened this issue Dec 11, 2014 · 15 comments
Closed

websockets #194

vlad-dragos opened this issue Dec 11, 2014 · 15 comments
Labels

Comments

@vlad-dragos
Copy link

Hi,

I'm working on a personal project that uses websockets. I'm currently refactoring my app to use the new aiohttp.web API and from what I see in the source code there is a start_websocket method in the aiohttp.web.Response class. Is there any way that I can help with the development on that so it gets added? :)

@fafhrd91
Copy link
Member

Sure! I think it is pretty strait forward. start_websocket() should accept request parameter same as start(), it should initiate websocket handshake, and return reader and writer objects. Similar to websocket examples

@fafhrd91
Copy link
Member

@fafhrd91
Copy link
Member

start_websocket() is StreamResponse's method. It can return just reader object and for writing we can reuse write() and write_eof() methods @asvetlov thoughts?

@vlad-dragos
Copy link
Author

I was thinking of passing the RequestHandler to the request and work all the magic in start_websockets. And then when you want to close the websocket we can call a close_websocket method on the request object. This way the logic remains in the handler. I'm going to make a push in a couple of hours with the code from my app ported to the library.

@fafhrd91
Copy link
Member

passing RequestHandler is bad idea.

@vlad-dragos
Copy link
Author

I meant passing the instance not the class :)

Sent from my iPhone

On 11 Dec 2014, at 20:37, Nikolay Kim notifications@github.com wrote:

passing RequestHandler is bad idea.


Reply to this email directly or view it on GitHub.

@fafhrd91
Copy link
Member

passing request handler instance into request is bad idea

@vlad-dragos
Copy link
Author

OK I was running some tests and I get this error:
Exception in callback <bound method _SelectorSocketTransport._read_ready of <asyncio.selector_events._SelectorSocketTransport object at 0x10e3e26a0>>() handle: Handle(<bound method _SelectorSocketTransport._read_ready of <asyncio.selector_events._SelectorSocketTransport object at 0x10e3e26a0>>, ()) Traceback (most recent call last): File "/usr/local/Cellar/python3/3.4.1_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/events.py", line 39, in _run self._callback(*self._args) File "/usr/local/Cellar/python3/3.4.1_1/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/selector_events.py", line 475, in _read_ready keep_open = self._protocol.eof_received() AttributeError: 'HandlerManager' object has no attribute 'eof_received'

Why would the the HandleManager be called in _SelectorSocketTransport?

@vlad-dragos
Copy link
Author

I made a pull request on master.

@amirouche
Copy link

I made an quick hack to make work websockets with the high level api. Probably not the best way to go.

@fafhrd91
Copy link
Member

@amirouche aiohttp already has websockets support, no need for external package. -1

@vlad-dragos btw what it the status?

@vlad-dragos
Copy link
Author

@fafhrd91 the code is ready but wirh the end of the year it was a bit chaotic and I haven't had the time to do the unit test. I was planing on doing them this weekend.

@fafhrd91
Copy link
Member

sounds good!

@fafhrd91
Copy link
Member

fafhrd91 commented Jan 3, 2015

websockets implemented in #220

@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

3 participants