Problems doing a user.push

6 views
Skip to first unread message

Brian Burton

unread,
Feb 6, 2016, 12:31:11 PM2/6/16
to Coronium IO
Hi Chris,
I'm stuck trying to do a coronium.user.push.  Hoping that you can point me in the right direction.

Here's what I am doing (and if there is a better way, please let me know!!):
I am pulling the users.objectId  by doing a search on the email address which is stored in _users with this call to the server:

Client: 
mc:run("notification", {to = receipents[i].to}, pusher)

Server (notification.lua):
local in_data=coronium.input()
local answer = coronium.user.getUsers({email=in_data.to},{objectId = 1})
coronium.output(answer)



The results go to my push function:

Client
local function pusher(event)
print("pusher function")  -- make sure we reached the function and know where to fix stuff.
        table.print_r(event.result)
if event.result[1].objectId then 
local temp = event.result[1].objectId
mc:run("pusher", {to = temp})
else
print("problem with data back in pusher", event.error)
end
end

Sample results:
pusher function
table: 033CB338 {
 [1] => table: 033CB338 {
   [objectId] => "a0a1572b02"
   }
}
error: Server Error - Check Logs
errorCode: 500

So we know I am getting the objectId which is passed to the server pusher.lua file:
pusher.lua (server)
local in_data=coronium.input()

local pushData = {
userId = in_data.to,
message = "You have received a new message",
}

answer = coronium.user.push(pushData)


if not answer.error then
  coronium.output( "push sent")
else
  coronium.output(answer.error)
end.


error.log
2016/02/06 17:34:57 [error] 7502#0: *283666 lua entry thread aborted: runtime error: /usr/local/coronium/lib/mod_user.lua:439: attempt to index field 'result' (a nil value)
stack traceback:
coroutine 0:
	/usr/local/coronium/lib/mod_user.lua: in function 'push'
	/home/coronium/lua/push.lua:10: in function </home/coronium/lua/pusher.lua:1>, client: 150.252.229.176, server: , request: "POST /1/code/pusher HTTP/1.1", host: "ec2-54-88-76-212.compute-1.amazonaws.com"



Any advice?

Thank you,
Brian


Brian Burton

unread,
Feb 7, 2016, 2:59:37 PM2/7/16
to Coronium IO
After some more trouble shooting, I found that the error was caused by not having the keys set properly in Coronium.
I think I am now sending push requests, but I'm not receiving them on my test device.  Any ideas or advice?

Thank you,
Brian

develephant

unread,
Feb 7, 2016, 3:36:19 PM2/7/16
to Coronium IO
Well that's semi-good news.

It tends to be certificate related. You should email sup...@pushbots.com - they should be able to verify everything.

Cheers.
Reply all
Reply to author
Forward
0 new messages