0

I have a great headache.
I have a running 'web-app', writed whith Rails4, in production hosted on a Google Compute Engine virtual machine with Ubuntu 14.04, where I use Rpush gem/Firebase for notification to an Android app 'my-app'.

Locally I use a similar configuration for development: an environment rvm with same Rails version. Simultaneously, with AndroidStudio, I'm developing 'my-app' android app.
On Ubuntu 16.04.

When Rails/Rpush send a notification, I receive it on 'my-app'.
So I controls both sides of notification process (except Firebase as middle tier).
Great.

It worked fine until some days ago.

Production enviroment continues to working well.
Locally, on development, when 'web-app' send a notification (through RPush/Firebase) I don't receive any kind of message, but I receive it in production, on 'released-version' of 'my-app' !!!

Normally, working local, when 'local' 'web-app' send notification, 'local' 'my-app' receive it;
in production, when 'host' 'we-app' send notification, 'released-version' of 'my-app' receive it.

For a few days is like if, in Firebase, in middle tier, each notification is broadcasted through 'released-version' of 'my-app', also if came from 'local' debug environment !!

Same releases for both envs.
It worked well until a few days ago.
Surely I've touched somethings ... the project is in progess.

I've much debugged, I've controlled many times configurations (local, host and Firebase) read many logs without results.
Everything seems working well !!

Someone know some ways to show me how debugging/understand this mysterious (for me) behavior ?

In Rails, when a message is saved, is triggered a method to push notification as described in GitHub by RPush repository.

In Android, in class 'MyFirebaseMessagingService extends FirebaseMessagingService', on overrided method 'onMessageReceived(RemoteMessage remoteMessage)' I receive messages (notification or data) - following 'quickstart-android/messaging' example.

In Firebase I have a project where I take 'Server Key' and 'google-services.json'.

My headache is growing.
Any advice is welcome.

UPDATE 20180326

I upgrade my question with code executed when sending message, configuration and an extract of rpush log (Rails server side - both local and hosted).

Rails method triggered after save 'Message'

def notify_gcm(data)
  if Rpush::Gcm::App.find_by_name(<firebase_app>).nil?
    app = Rpush::Gcm::App.new
    app.name = <firebase_app>
    app.auth_key = <firebase-server_key>
    app.connections = 1
    app.save!
  end
  n = Rpush::Gcm::Notification.new
  n.app = Rpush::Gcm::App.find_by_name(<firebase_app>)
  n.delay_while_idle = true
  n.registration_ids = [<device_token>, ...]
  n.priority = 'high'
  n.content_available = true
  # notification type: DATA MESSAGE
  n.data = { data: { message: data[:message]["content"] }, notificationdata: { body: ..., title: ..., icon: ... }
  }
  n.save!
  Rpush.push
end

config/initializers/rpush

Rpush.configure do |config|
  config.client = :active_record
  config.push_poll = 5
  config.batch_size = 100
  config.pid_file = 'tmp/rpush.pid'
  config.log_file = 'log/rpush.log'
  config.log_level = (defined?(Rails) && Rails.logger) ? Rails.logger.level : ::Logger::Severity::ERROR
end

Rpush log

BEGIN
  INSERT INTO `rpush_notifications` (`type`, `app_id`, `delay_while_idle`, `registration_ids`, `priority`, `content_available`, `data`, `created_at`, `updated_at`) VALUES (...)
COMMIT
SELECT `rpush_apps`.* FROM `rpush_apps`[<firebase_app>] Starting 1 dispatcher... 
SELECT COUNT(*) FROM `rpush_notifications` WHERE (processing = 0 AND delivered = 0 AND failed = 0 AND (deliver_after IS NULL OR deliver_after < '2018-03-25 10:27:22.719515'))
BEGIN
  SELECT `rpush_notifications`.* FROM `rpush_notifications` WHERE (processing = 0 AND delivered = 0 AND failed = 0 AND (deliver_after IS NULL OR deliver_after < '2018-03-25 10:27:22.720521'))  ORDER BY created_at ASC LIMIT 100 FOR UPDATE
  UPDATE `rpush_notifications` SET processing = 1 WHERE  rpush_notifications`.`id` = 210 
COMMIT
SELECT COUNT(*) FROM `rpush_notifications` WHERE (processing = 0 AND delivered = 0 AND failed = 0 AND (deliver_after IS NULL OR deliver_after < '2018-03-25 10:27:22.774452'))
SELECT  `rpush_apps`.* FROM `rpush_apps` WHERE `rpush_apps`.`id` = 1 LIMIT 1

[<firebase_app>] 210 sent to ... <proper registration_ids>

Rpush is started as a daemon by commandline:

rpush start -e production

rfellons
  • 656
  • 12
  • 28
  • Hard to provide a good answer about what might have changed without seeing any code. I'd recommend setting up separate Firebase projects -- one for production, and one for dev. Then when you're working in the dev environment point to your dev Firebase project, and remember to ship new releases with the pointer to the production Firebase project. This would provide some peace of mind in the future that a code/config change doesn't cause the issue again. See answer here: https://stackoverflow.com/questions/37450439/separate-dev-and-prod-firebase-environment – settheline Mar 24 '18 at 22:13
  • Thanks @settheline for your advise. I will consider your view. But this happen to me when I use only one Firebase configuration ... with separate settings I think I can fall down in many more errors, but surely is a more methodical way to working. – rfellons Mar 26 '18 at 08:00

1 Answers1

0

SOLVED

Gemfile

removed gem 'rails_12factor', group :production

this it was been previously removed to hosted (production) :(

rfellons
  • 656
  • 12
  • 28