Greetings!
I'm trying to synchronize data between several nodes via nanomsg. I've
written a simple test app that is executed on two computers and sends
packets from one to another. There are two issues that I didn't expect,
so I'm asking for some help or explanation.
Issue 1: Each node tries to find out if another node is already up and
running. If it is, the node enters slave mode and begins to listen for
packets, otherwise it enters master mode and sends packets every 500 ms.
I've tried to use nn_poll for master detection, but it always says that
another node can send messages, and does not say if it actually does
send anything. So I've written a simple function:
boolamIaSlave(intinBus,char*buf)
{
//waitforamaster'scall
for(inti=0;i<20;++i)
{
if(nn_recv(inBus,buf,10,NN_DONTWAIT)>0)
returntrue;
nn_sleep(100);
}
returnfalse;
}
As the server sends data every 500 ms, 20 checks over 2 seconds total
shoud be more than sufficient to find out if the server is alive. It
isn't, though. I had to insert a 1000 ms nn_sleep between initializing
buses and calling amIaSlave function to have it return true sometimes,
and even then it returns false (although another server is running) from
time to time. So the question is: is there a way of robust
identification of another nodes with nanomsg running and sending data?
Issue 2: I expected a scalability protocol library to be able to
reliably deliver messages even if the connection has been lost for some
time. I've had my test app running on two PCs, one of which is a
notebook, and 've disconnected Wi-Fi for some time to see if [numbered]
messages sent while the connection was lost would be delivered when it's
restored. They weren't. Is it expected behavior or is something wrong?
Thanks in advance. Perhaps some of these questions were already asked,
please link me to the topic if they were. I found no info on this matter
in nanomsg documentation, and the mailing list archive seems to be only
browsable by time period, making it inconvenient to search.
--
С уважением,
Kirill Didkovsky