-
Notifications
You must be signed in to change notification settings - Fork 6
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
Stops working after a while (probably user error) #2
Comments
I should also mention that if I simply kill and restart the node.js app, the cordova app sees the announcement. |
Hi @keyvanfatehi thanks for being interested :-) Let's see if I can shine some light in the black box by giving a general description. First off, let me say that Diont on Cordova works exactly the same as on NodeJS. So everything I write below, is valid for both. Let's start with requiring and calling Diont, like this:
Once Diont is called, it will check whether it has access to the proper UDP port on the network, and if so it will send a 'query' request to the network (not to a specific machine, but to the network in general; a broadcast so to say) to ask if there is any servers that have announced services. If a Diont server has an announced service, it will respond to the query message by re-announcing all its services to the network: that means sending a single UDP message to the network with all the information about the announced service in it. If a server has no announced services, it will ignore the query request and do nothing. To summarize this part: on 'startup', Diont will actively query the network for services, and the Diont servers on the network respond with their announced services. Next, we can announce a service ourselves. If we do that, two things happen:
When renouncing a service, the opposite happens:
If you have a flaky network and you want to make sure that you have all the service announcments that are available on the network, you could periodically run
And the servers that have announced services should re-announce their services. Does that make sense? |
That being said, if you are announcing new services from Diont A, and suddenly they don't arrive on the other Diont instances (say B and C), that means that either A or B and C have no access to the network anymore, or there is some other network issue going on, preventing messages to arrive at the proper places. Are you announcing the messages from Cordova or from NodeJS? |
@willemmulder That was a great explanation, it's completely clear now -- thank you very much! To answer your question I am announcing from Node.js. I will mark this as closed. It seems that my original issue was due to my network, my incorrect use of diont in Cordova, my ignorance about how it worked, and the not knowing that I can simply call |
Haha, no problem. If you could add a line or two about the .queryForServices method somewhere in the readme, I'll gladly accept it; might be useful for others to know as well: I forgot to mention it there! |
Hi Willem I plan to extend the documentation a bit, but I want to think about it a On Tue, Aug 18, 2015 at 12:23 PM, Willem Mulder notifications@github.com
|
Perfect, thanks a lot Keyvan! Looking forward to it. |
Hi Willem,
Thanks for making Diont!
I have an issue and some questions about how this all works and how to use it correctly.
I'm announcing from a node process and listening from a cordova app, using your packages for both sides.
I was hoping you could shed some light on the proper way to use this for continued, long-term use.
Diont is working great although it seems that after some time, my cordova client no longer sees my node process's announcements.
5 How does this all even work, conceptually?
Unforunately I've not studied UDP nearly enough to grok this from your code -- it seems like black magic to me that it's even working.
Thanks very much in advance--I hope you've the time to respond.
The text was updated successfully, but these errors were encountered: