Closed tomwilsn closed 7 years ago
What does your scheduled task look like?
It works fine if I call it myself, but if the server sits there all day when it comes time to run it I get the error above : (
def send_reminders() do
Logger.info("Sending reminders")
Repo.all(PushToken, [type: "apns"])
|> Enum.map(&(%{push_token: &1, notification: Pigeon.APNS.Notification.new(nil, &1.token, "topic") |> put_content_available}))
|> Enum.each(fn(item) ->
Pigeon.APNS.push(item.notification, fn(x) ->
case x do
{:ok, notification} ->
Logger.debug("Push successful!")
{:error, :bad_device_token, message} ->
delete_token(item.push_token)
{:error, :unregistered, message} ->
delete_token(item.push_token)
{:error, reason, message} ->
Logger.error("Some other error happened: #{inspect message}")
end
end)
end)
end
@doc "Deletes the specified token"
def delete_token(push_token) do
case Repo.delete(push_token) do
{:ok, struct} ->
Logger.info("Deleted invalid token")
{:error, changeset} ->
Logger.error("Error deleting invalid token: #{changeset.id}")
end
end
Does it throw this error every time it gets called from quantum? Looks like the HTTP2 socket might be timing out.
Edit @arkadiyk I just now found your issue at https://github.com/joedevivo/chatterbox/issues/89. I'm guessing chatterbox doesn't keep the connection alive on its own.
Yeah, chatterbox doesn't do anything to keep the connection alive. Although in my case the symptoms are different. When connection times out the error message comes few minutes later and it's easy to overlook it.
Probably worth to try using version with the ping just to see if it fixes the problem:
{:pigeon, git: "https://github.com/codedge-llc/pigeon.git", ref: "fb7ff8d6d6"},
Btw, I am still using this version in prod.
That seems to be working 👍
I am getting this error when trying to send messages from a task that was scheduled with quantum (https://github.com/c-rack/quantum-elixir)
Any ideas?