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

Websocket can't work properly #190

Open
zkonge opened this Issue Nov 3, 2018 · 6 comments

Comments

4 participants
@zkonge
Copy link

zkonge commented Nov 3, 2018

When I sent a websocket request in browser, a 500 error appeared. Then I find something interesting in api.py.api.py#L222
It seems that 'models.Request' is not ready for websocket yet (accept 'http' not 'ws'). Do you have any plan to complete the feature?

These are my test code.

import responder

api = responder.API()

@api.route('/ws', websocket=True)
async def wsk(ws):
    await ws.accept()
    await ws.send_text("Hello via websocket!")
    await ws.close()

api.run()
const st = new WebSocket('ws://localhost:5042/ws');

st.addEventListener('message', function (event) {
    console.log('Message from server ', event.data);
});
@taoufik07

This comment has been minimized.

Copy link
Contributor

taoufik07 commented Nov 3, 2018

It's under redesign

@Serkan-devel

This comment has been minimized.

Copy link

Serkan-devel commented Nov 3, 2018

Are websockets even documented here?

@taoufik07

This comment has been minimized.

Copy link
Contributor

taoufik07 commented Nov 3, 2018

They were, but now nope

@kennethreitz

This comment has been minimized.

Copy link
Owner

kennethreitz commented Nov 4, 2018

what's the problem?

Repository owner deleted a comment from taoufik07 Nov 4, 2018

@zkonge

This comment has been minimized.

Copy link

zkonge commented Nov 6, 2018

In api.py, models.Request is used whatever the request protocol is http or websocket, but in starlette.Response.py, which shows that the Request should only instantiate when it's a http request.

@kennethreitz

This comment has been minimized.

Copy link
Owner

kennethreitz commented Nov 6, 2018

PRs accepted!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment