Trying to use the GroupMe gem EM-C2DM, https://github.com/groupme/em-c2dm, a Google C2DM Ruby Library using Event Machine, within Rails. I know it should work on Heroku as there is a configuration specific to Heroku, however I can't seem to get it to run.
I'm executing via a Resque Worker, and the worker works correctly and gets queued and called. However it fails to ever get past authenticating and never reports on the response of the push notification. It seems to just never finish.
module PushAndroid
require "eventmachine"
require "em-c2dm"
@queue = :android_push
def self.perform(opts)
puts "entering android push"
EM.next_tick do
EM::C2DM.authenticate(ENV["C2DM_EMAIL"], ENV["C2DM_PASSWORD"])
@push = Push.find(opts['push_id'])
message = "Message #{@push.title}"
push_id = "#{@push.id}"
opts['tokens'].each{ |token|
EM::C2DM.push(token, :message => message, :push_id => push_id) do |response|
if response.success?
puts "success! id=#{response.id}" # ID of sent message
else
puts "response:"
puts response.inspect
#case response.error
#when "InvalidToken"
# reauthenticate
#when "InvalidRegistration"
# clear our registration id
#when "RetryAfter"
# pause sending for response.retry_after seconds
#end
end
end
}
end
end
end
I've also tried it without using EM::next_tick or EM.next_tick and it gets past authentication, however never pushes anything, never returns a response or anything. It never enters EM::next_tick in fact.
Any ideas on how to get this to work? This is on Heroku, using Rails 3.1.1 with Thin
From my Gemfile.lock:
thin (1.3.1)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
eventmachine (1.0.0.beta.4)
em-apn (0.0.3)
eventmachine (>= 1.0.0.beta.3)
yajl-ruby (>= 0.8.2)
em-http-request (1.0.2)
addressable (>= 2.2.3)
cookiejar
em-socksify
eventmachine (>= 1.0.0.beta.4)
http_parser.rb (>= 0.5.3)
em-socksify (0.2.0)
eventmachine (>= 1.0.0.beta.4)
remote: git://github.com/groupme/em-c2dm.git
revision: 2d853ff771908785f23b8c64fa5d5508b4eba40a
specs:
em-c2dm (0.0.1)
em-http-request (>= 1.0.0.beta.4)
eventmachine (>= 1.0.0.beta.3)
uuid