Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling 'DOWN' connection when sending message using send_message #47

Closed
monkeyfdude opened this issue Feb 27, 2015 · 4 comments
Closed

Comments

@monkeyfdude
Copy link

I observe following code in test_suite:

apns:send_message(
  ?TEST_CONNECTION, ?DEVICE_TOKEN,
  Now ++ " - Test Alert", random:uniform(10), "chime"),

receive
{'DOWN', Ref, _, _, _} = DownMsg ->
throw(DownMsg);
DownMsg ->
throw(DownMsg)
after 1000 ->
ok
end,

If I understand this correctly (new to Erlang) its looking for "DOWN" message which will come as part of connection monitoring if the connection goes down - Ref = erlang:monitor(process, Pid),

  • Does "after -> 1000" mean that apns worker will go down after 1 sec it detected a connection "DOWN"?
  • Would this mean that message will be lost?
  • Would apns_sup restart the worker process, reset the connection?
  • What needs to be done for the message which was being sent when connection was detected 'DOWN'

Please guide me to understand this better.

@manuel-rubio
Copy link
Contributor

If you send a message and the connection is down, maybe your token is not valid. What do you see in the logs?

@monkeyfdude
Copy link
Author

I was just looking at the unit test and saw code I mentioned above. It got me thinking.

I was just trying to understand what should be the behavior when the connection does go down for some reason.
Or you don't expect the connection to go down at all???

What be the role of supervisor in this case?

@monkeyfdude
Copy link
Author

I get this error on pans:connect

2015-02-27 17:13:33.767 [info] <0.7.0> Application apns started on node ejabberd@localhost
2015-02-27 17:13:33.779 [error] <0.382.0> Unable to load crypto library. Failed with error:
"load, Library load-call unsuccessful."
OpenSSL might not be installed on this system.

2015-02-27 17:13:33.779 [error] <0.380.0> CRASH REPORT Process <0.380.0> with 1 neighbours exited with reason: call to undefined function crypto:supports() in gen_server:init_it/6 line 330
2015-02-27 17:13:33.779 [error] <0.383.0> The on_load function for module crypto returned {error,{load,"Library load-call unsuccessful."}}
2015-02-27 17:13:33.779 [error] <0.375.0> Not Successfully Started connection

EDIT:

I could resolve the above issue by:

processone/ejabberd#406

@monkeyfdude
Copy link
Author

I am able to use apns4erl successfully...I may have other architecture questions...I will ask in separate ticket

Thank you all for your help and support.....can not be expressed in words!!!!!!!!!!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants