pusher-community / pusher-websocket-ruby

Ruby WebSocket client for Pusher Channels
https://pusher.com/channels
MIT License
61 stars 61 forks source link

SSL read_nonblock #39

Closed spradlig closed 10 years ago

spradlig commented 10 years ago

So I've worked with Ruby some but wouldn't qualify myself and strong in Ruby. However, the PHP library for a pusher client is broken and so I was attempting to get the Ruby one working.

It appears to connect but then bomb when getting a message. The test script subscribes to 2 channels and then uses your

# Bind to a channel event
socket['channel1'].bind('event') do |data|
  pp data
end

code to bind the channel message. Here's my error message.

D, [2014-04-11T18:35:51.008473 #31607] DEBUG -- : Pusher : connecting : wss://ws.pusherapp.com:443/app/##############?client=pusher-ruby-client&version=0.4.0&protocol=5
D, [2014-04-11T18:35:51.200289 #31607] DEBUG -- : Websocket connected
/var/lib/gems/1.8/gems/pusher-client-0.4.0/lib/pusher-client/websocket.rb:66:in `receive': undefined method `read_nonblock' for #<OpenSSL::SSL::SSLSocket:0x7f52b1b70100> (NoMethodError)
        from /var/lib/gems/1.8/gems/pusher-client-0.4.0/lib/pusher-client/socket.rb:68:in `connect'
        from /var/lib/gems/1.8/gems/pusher-client-0.4.0/lib/pusher-client/socket.rb:67:in `loop'
        from /var/lib/gems/1.8/gems/pusher-client-0.4.0/lib/pusher-client/socket.rb:67:in `connect'
        from /var/lib/gems/1.8/gems/pusher-client-0.4.0/lib/pusher-client/socket.rb:62:in `initialize'
        from /var/lib/gems/1.8/gems/pusher-client-0.4.0/lib/pusher-client/socket.rb:62:in `new'
        from /var/lib/gems/1.8/gems/pusher-client-0.4.0/lib/pusher-client/socket.rb:62:in `connect'
        from pusher_test.rb:27

Here are my gems:

* LOCAL GEMS *

clipboard (1.0.5) commonwatir (4.0.0) dalli (2.7.0) firewatir (1.9.4) headless (1.0.1) json (1.8.1) multi_json (1.8.4) mysql (2.9.1) narray (0.6.0.8) pusher-client (0.4.0) websocket (1.0.7)

I'm running Ubuntu 12.04 with Ruby 1.8.7 (I think that is the version Ubuntu installs by default. I haven't changed it from Ubuntu's default.)

My googling led to lots of other gems having this issue and some fingers pointing at jruby but I can't say they seemed conclusive.

spradlig commented 10 years ago

Sorry for the formatting, never posted an issue on git before.

zimbatm commented 10 years ago

It's okay, I fixed the formatting. My guess is that it's an issue with ruby 1.8.7. This version is very old and now unsupported by the core developers. Ubuntu 12.04 has a ruby1.9.1 package I think or you could install another version from source. There's various utilities like ruby-build, ruby-install and RVM that help you with that.

zimbatm commented 10 years ago

Fixed on master