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

Solves #388, connection problems with latest faye-websocket version. #430

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

phlegx
Copy link

@phlegx phlegx commented Sep 8, 2016

The gem faye-websocket has an example on the github site where it calls ws.rack_response to return an async (non-blocking) Rack response. This pull request does exactly the same for websocket-rails gem.

Tested and working with faye-websocket 0.10.4. Solves issue #388!

# Faye-websocket example
require 'faye/websocket'

App = lambda do |env|
  if Faye::WebSocket.websocket?(env)
    ws = Faye::WebSocket.new(env)

    ws.on :message do |event|
      ws.send(event.data)
    end

    ws.on :close do |event|
      p [:close, event.code, event.reason]
      ws = nil
    end

    # Return async Rack response
    ws.rack_response

  else
    # Normal HTTP request
    [200, {'Content-Type' => 'text/plain'}, ['Hello']]
  end
end

@recurser
Copy link

I've been locked on 0.10.0 for months, and this fixes the issue for me 👍

Nice work @phlegx!

@Uelb
Copy link
Contributor

Uelb commented Jul 10, 2017

@phlegx You just made my day

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 this pull request may close these issues.

None yet

3 participants