Closed maynardewm closed 6 years ago
Does it fail every time? Can you configure logging, turn it up, and let us know what's in the log please? Library version and time would also be great so we can check what's happening on our side for your request.
Library version: 4.1.0
When I try to tail the development.log file, I get an error:
Completed 401 Unauthorized in 37ms (ActiveRecord: 7.4ms)
Errno::ENOENT (No such file or directory @ rb_sysopen - log/urbanairship.log):
Here's the log output when I try to make the UA Notification:
Started POST "/api/1/posts/8289797122/likes.json" for 23.240.151.231 at 2018-03-15 18:10:49 +0000
Cannot render console from 23.240.151.231! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by Api::LikesController#create as JSON
Parameters: {"post_key"=>"8289797122"}
Can't verify CSRF token authenticity.
User Load (0.3ms) SELECT users
. FROM users
WHERE users
.id
= 1 LIMIT 1
Post Load (0.2ms) SELECT posts
. FROM posts
WHERE posts
.key
= '8289797122' LIMIT 1
(0.2ms) SELECT COUNT() FROM likes
WHERE likes
.post_id
= 36 AND likes
.user_id
= 1
(0.1ms) BEGIN
Post Load (0.2ms) SELECT posts
. FROM posts
WHERE posts
.id
= 36 LIMIT 1
CACHE User Load (0.0ms) SELECT users
. FROM users
WHERE users
.id
= 1 LIMIT 1 [["id", 1], ["LIMIT", 1]]
SQL (0.2ms) INSERT INTO likes
(post_id
, user_id
, created_at
, updated_at
) VALUES (36, 1, '2018-03-15 18:10:49', '2018-03-15 18:10:49')
(2.4ms) COMMIT
User Load (0.2ms) SELECT users
. FROM users
WHERE users
.id
= 2 LIMIT 1
(0.1ms) BEGIN
SQL (2.1ms) INSERT INTO notifications
(user_id
, notified_by_id
, notifiable_type
, notifiable_id
, notification_type
, created_at
, updated_at
) VALUES (2, 1, 'Post', 36, 'like', '2018-03-15 18:10:49', '2018-03-15 18:10:49')
(2.9ms) COMMIT
(0.2ms) SELECT COUNT() FROM devices
WHERE devices
.user_id
= 2
Device Load (0.2ms) SELECT devices
. FROM devices
WHERE devices
.user_id
= 2
Completed 401 Unauthorized in 47ms (ActiveRecord: 12.5ms)
Errno::ENOENT (No such file or directory @ rb_sysopen - log/urbanairship.log):
app/controllers/api/likes_controller.rb:86:in block in create_notification' app/controllers/api/likes_controller.rb:79:in
create_notification'
app/controllers/api/likes_controller.rb:25:in `create'
Thanks! Looks like something may still be weird with your library logging setup.. did you follow the steps here? https://github.com/urbanairship/ruby-library#configuration
The config is correct I believe:
require 'urbanairship'
Urbanairship.configure do |config|
config.log_path = 'log'
config.log_level = Logger::WARN
end
It works when I run the server like this: rails s -b 0.0.0.0
But not like this: rails s -d -b 0.0.0.0
Ok, thanks for your patience! We're hoping to be able to dig into this early next week.
Hi,
Could you tell me what version of ruby and rails you are running? Also is the daemon you're using a gem? If so, which gem/version are you using? If not, please send the daemon code you are using. Are you running the app from the root of the app directory?
Ruby 2.5.0 Rails 5.1.4 Puma in production, Webrick in dev
Yes I am running from root of app directory
Hi,
I've been talking about this with the engineers here and the issue, in terms of logging, may be that you are specifying the config.log_path value as 'log', but Ruby loggers won't automatically create that directory. Could you please create the log directory and try to send again.
I couldn't get any config.log_path settings to work, so I removed it for now so at least it works.
Hi,
I just want to clarify. Are you able to run the server as rails s -d -b 0.0.0.0 and have push notifications go out now?
Expected Behavior
Push notification should be sent to device.
Current Behavior
It works if I run the server as: rails s -b 0.0.0.0, but not if I run the server as rails s -d -b 0.0.0.0
I get the following error:
Possible Solution
Is it a permissions issue?
Rails Server Code