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

cramp websockets not work on Thin since faye-websocket ~> 0.7.1 #64

Closed
mateuszdw opened this issue May 31, 2014 · 2 comments · Fixed by #67
Closed

cramp websockets not work on Thin since faye-websocket ~> 0.7.1 #64

mateuszdw opened this issue May 31, 2014 · 2 comments · Fixed by #67

Comments

@mateuszdw
Copy link

Since cramp is depedent of 'faye-websocket', '~> 0.7.1' I have problem with websockets connection. Looks like Thin breaking something
On latest version websockets response looks like this:

GET /chat HTTP/1.1
Host: localhost:3001
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: PuTGxkRU5cjY8PZ5Y4+4mQ==
Sec-WebSocket-Version: 13

HTTP/1.1 101 Switching Protocols
Connection: keep-alive
Server: thin 1.6.2 codename Doc Brown

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: itIs6clgPwlktYYxEOu6s2pMNs8=

HTTP/1.1 200 OK
Connection: keep-alive
Server: thin 1.6.2 codename Doc Brown
Content-Type: text/html

�{"action":"connected"}
{"action":"disconnected"}

Previous dependency'faye-websocket', '~> 0.4.6' gives

GET /chat HTTP/1.1
Host: localhost:3001
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: 5Iba1zzsP3lHZoR9dvNezQ==
Sec-WebSocket-Version: 13

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: gobdn6TEQiGIjj5vW2Vxtj9uMTE=

�{"action":"data"}
�{"action":"connected"}

Tested with 1.9.3-p392 and Gemfile dependencies

GEM
  remote: http://rubygems.org/
  specs:
    activesupport (3.2.18)
      i18n (~> 0.6, >= 0.6.4)
      multi_json (~> 1.0)
    async-rack (0.5.1)
      rack (~> 1.1)
    cramp (0.15.3)
      activesupport (~> 3.2.16)
      eventmachine (~> 1.0.3)
      faye-websocket (~> 0.7.1)
      rack (~> 1.5.2)
      thor (~> 0.18.0)
    daemons (1.1.9)
    eventmachine (1.0.3)
    faye-websocket (0.7.3)
      eventmachine (>= 0.12.0)
      websocket-driver (>= 0.3.1)
    http_router (0.11.1)
      rack (>= 1.0.0)
      url_mount (~> 0.2.1)
    i18n (0.6.9)
    multi_json (1.10.1)
    rack (1.5.2)
    thin (1.6.2)
      daemons (>= 1.0.9)
      eventmachine (>= 1.0.0)
      rack (>= 1.0.0)
    thor (0.18.1)
    unicode_utils (1.4.0)
    url_mount (0.2.1)
      rack
    websocket-driver (0.3.3)
    yajl-ruby (1.2.0)

PLATFORMS
  ruby

DEPENDENCIES
  async-rack
  cramp
  http_router
  thin
  unicode_utils
  yajl-ruby

So simple app in cramp does not work in current version

class WsAction < Cramp::Websocket
  on_start :on_start
  on_finish :on_finish
  on_data :on_data

  def on_start
  end
  def on_finish
  end
  def on_data
  end
end
@mateuszdw mateuszdw changed the title websockets and 'faye-websocket', '~> 0.7.1' not work cramp websockets not work since 'faye-websocket', '~> 0.7.1' May 31, 2014
@mateuszdw mateuszdw changed the title cramp websockets not work since 'faye-websocket', '~> 0.7.1' cramp websockets not work on Thin since faye-websocket ~> 0.7.1 May 31, 2014
@mateuszdw
Copy link
Author

this issue can be related with commit faye/faye-websocket-ruby@799103f

@chall8908
Copy link
Contributor

I recently ran across this problem myself and isolated the problem to Cramp's send_initial_response method. It was erroneously sending additional responses after a WebSocket connection had been negotiated by Faye, thus displaying the errors you were seeing. I have an open PR that appears to fix the problem.

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

Successfully merging a pull request may close this issue.

2 participants