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

Unable to get websockets working with http4s example #2

Closed
dcapwell opened this issue Apr 22, 2014 · 4 comments
Closed

Unable to get websockets working with http4s example #2

dcapwell opened this issue Apr 22, 2014 · 4 comments
Assignees
Labels

Comments

@dcapwell
Copy link

I am running the sample from https://github.com/http4s/http4s/blob/develop/examples/src/main/scala/org/http4s/examples/blaze/BlazeWebSocketExample.scala and trying to upgrade to ws. It seems that the handshake doesn't work as expected, nor can I get a javascript example to talk to the endpoint.

Here is the test (control):

$ curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: echo.websocket.org" -H "Origin: http://www.websocket.org" http://echo.websocket.org
HTTP/1.1 101 Web Socket Protocol Handshake
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: content-type
Access-Control-Allow-Headers: authorization
Access-Control-Allow-Headers: x-websocket-extensions
Access-Control-Allow-Headers: x-websocket-version
Access-Control-Allow-Headers: x-websocket-protocol
Access-Control-Allow-Origin: http://www.websocket.org
Connection: Upgrade
Date: Tue, 22 Apr 2014 17:52:24 GMT
Server: Kaazing Gateway
Upgrade: WebSocket
WebSocket-Location: ws://echo.websocket.org/
WebSocket-Origin: http://www.websocket.org

^C

$ curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: html5rocks.websocket.org" -H "Origin: http://www.websocket.org" http://html5rocks.websocket.org/echo
HTTP/1.1 101 Web Socket Protocol Handshake
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: content-type
Access-Control-Allow-Headers: authorization
Access-Control-Allow-Headers: x-websocket-extensions
Access-Control-Allow-Headers: x-websocket-version
Access-Control-Allow-Headers: x-websocket-protocol
Access-Control-Allow-Origin: http://www.websocket.org
Connection: Upgrade
Date: Tue, 22 Apr 2014 17:55:03 GMT
Server: Kaazing Gateway
Upgrade: WebSocket
WebSocket-Location: ws://html5rocks.websocket.org/echo
WebSocket-Origin: http://www.websocket.org

^C

I now try the same curl with the endpoint power by blaze:

$ curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: localhost" -H "Origin: http://www.websocket.org" http://localhost:8080/http4s/ws
HTTP/1.1 400 Bad Request
Content-Length: 28
Connection: close

Bad Websocket Version header

Ok, so let me add the version and key (I would expect the server to reply with what version it supports: https://tools.ietf.org/html/rfc6455#section-11.3.5)

$ curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: localhost" -H "Origin: http://www.websocket.org" -H "Sec-WebSocket-Version: 13" -H 'Sec-WebSocket-Key: +onQ3ZxjWlkNa0na6ydhNg==' http://localhost:8080/http4s/ws
^C

Not getting back the handshake headers, but the connection is made, so now trying from javascript. There is a simple example found here: http://www.websocket.org/echo.html. When I put ws://localhost:8080/http4s/ws and try to connect, I see that the connection is still pending in chrome, client never sees that the connection is "connected". Trying the two control endpoints above work as expected.

@bryce-anderson
Copy link
Member

Sorry for the slow reply, I didn't get a notification. The websocket support is certainly a work in progress which has take lower priority than stabilizing the http parser and NIO backends. I've been using chrome browsers to test websockets and the , and I hear that firefox isn't working so there is a good chance I've done something very version specific. I'm hoping to have a bit of time this weekend to hit some soar spots in here so I'll add this to the list.

@bryce-anderson bryce-anderson self-assigned this Jun 5, 2014
@bryce-anderson
Copy link
Member

This issue was partially addressed with commit f9d0738. Further investigation to all problems still pending.

@javadba
Copy link

javadba commented Dec 27, 2016

Hi - 2.5 years later. Is Websockets working with http4s?

@rossabaker
Copy link
Member

Only on the blaze-server (no clients, no server backends), but yes. There is a runnable example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants