CESNET / libnetconf

C NETCONF library
Other
113 stars 84 forks source link

notifications not working correctly after server restart #170

Closed ntadas closed 8 years ago

ntadas commented 8 years ago

Hi,

The scenario I'm testing is the following: 1- I start my server (everything is clean). 2- connect a client and subscribe it to receive notifications 3- generate notifications A, B and C 4- kill the server and start it again (without touching the working dir). 5- connect a client and subscribe it to receive notifications 6- generate notifications D e and F 7- client receives notifcations A B and C

I'm using the method ncntf_event_new(-1, NCNTF_GENERIC, notifString) to send the notifications and the ncntf_dispatch_send(sessionId, subscriptionRpc); to dispatch them.

Regards Nuno

rkrejci commented 8 years ago

I'm not able to reproduce the issue. What exactly is the content of the subscription message? I had

<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
  <create-subscription xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0"/>
</rpc>

and then I had a simple code (notif.c) to generate notifications:

#include <libnetconf.h>
int main(int argc, char *argv[])
{
    nc_init(NC_INIT_SINGLELAYER | NC_INIT_NOTIF);
    ncntf_event_new(-1, NCNTF_GENERIC, argv[1]);
    nc_close();
    return 0;
}

and the scenario was:

  1. start netopeer-server (stream directory is empty and the server created rules and stream file there)
  2. connect netopeer-cli to the server and subscribe (no additional parameter specified)
  3. $ ./notif "<event>test1</event>"
  4. netopeer-cli received test1 notification
  5. disconnect netopeer-cli
  6. kill netopeer-server and start it again
  7. connect netopeer-cli and subscribe
  8. $ ./notif "<event>test2</event>"
  9. netopeer-cli received test2 notification

So, everything works as expected. Could you please test my scenario with the notif.c? The only reason for the behaviour you are describing I see in some parameters of the subscription RPC that would make ncntf_dispatch_send() sending the events from the past.

rkrejci commented 8 years ago

Maybe try to share more details about the notifications, what exactly (XML content including the time) does the client receive?

ntadas commented 8 years ago

Hi,

so the subscription message seems ok, its:

`

`

I've tested as you asked (with the sample program) and I have what you describe in your answer (also what I mention to be the problem). in your point 9 you state that your receive notification test1 shouldn't you receive test2? if not then my behaviour is also ok, but I would expect to see test2?

Regards Nuno

rkrejci commented 8 years ago

I had a typo in point 9, I've received correctly test2 notification.

If you get test1, then it is a bug, but I'm not able to reproduce it with netopeer-server. I have to think about it little more, we will see if I'll get some idea.

rkrejci commented 8 years ago

btw, I expect that you have only a single events file (NETCONF.events.) in your streams directory, right?

ntadas commented 8 years ago

Yes I only using this one. On 10 Mar 2016 1:08 p.m., "Radek Krejčí" notifications@github.com wrote:

btw, I expect that you have only a single events file (NETCONF.events.) in your streams directory, right?

— Reply to this email directly or view it on GitHub https://github.com/CESNET/libnetconf/issues/170#issuecomment-194834454.

ntadas commented 8 years ago

Maybe I'm missing some initialisation of the streams in my server? Do I have to do something special? On 10 Mar 2016 1:10 p.m., "Nuno Tadeu" nuno.tadeu@gmail.com wrote:

Yes I only using this one. On 10 Mar 2016 1:08 p.m., "Radek Krejčí" notifications@github.com wrote:

btw, I expect that you have only a single events file (NETCONF.events.) in your streams directory, right?

— Reply to this email directly or view it on GitHub https://github.com/CESNET/libnetconf/issues/170#issuecomment-194834454.

rkrejci commented 8 years ago

I believe that having NC_INIT_NOTIF in nc_init()'s flags parameter should be enough. The NETCONF stream as the default one should be initialized automatically.

ntadas commented 8 years ago

strange thing is that I send a notification test1, but after I restart the server I don't see this test1 in the stream, but the client receives it, where can this informatio nbe stored beside the stream?

On Thu, Mar 10, 2016 at 2:14 PM, Radek Krejčí notifications@github.com wrote:

I believe that having NC_INIT_NOTIF in nc_init()'s flags parameter should be enough. The NETCONF stream as the default one should be initialized automatically.

— Reply to this email directly or view it on GitHub https://github.com/CESNET/libnetconf/issues/170#issuecomment-194863759.

rkrejci commented 8 years ago

What does mean that "you don't see the test1 in the stream". How do you see on notifications in the stream?

ntadas commented 8 years ago

if I open the file ..../streams/NETCONF.events. I can see the notifications send (plain text + some binary data). so if I kill the server erase the streams folder, launch the server again and send a notification. I'm receiving a old notification but I cannot see it in the new stream file (in this file I only see the new ones).

On Thu, Mar 10, 2016 at 2:21 PM, Radek Krejčí notifications@github.com wrote:

What does meant that "you don't see the test1 in the stream". How do you see on notifications in the stream?

— Reply to this email directly or view it on GitHub https://github.com/CESNET/libnetconf/issues/170#issuecomment-194869342.

rkrejci commented 8 years ago

before you kill the server, try to check which applications have open the events file:

$ sudo lsof /var/lib/libnetconf/streams/NETCONF.events.<number>

Anyway, it is really strange, because when you erase the events file and start the server, the server should

In your case, it seems that the server detects a new event, but reads from the erased (unlinked) file and send the event from the erased file.

ntadas commented 8 years ago

found the problem, server is working as expected also netopeer-client, this is a problem of other client that I'm using. if I do the same test with 2 clients subscribing the notifications netopeer-cli will receive the correct notification but the other client will display a very old notification (so it seems to be some issue with the client). thanks for your time and sorry for this misunderstanding.

Regards Nuno

On Thu, Mar 10, 2016 at 2:40 PM, Radek Krejčí notifications@github.com wrote:

before you kill the server, try to check which applications have open the events file:

$ sudo lsof /var/lib/libnetconf/streams/NETCONF.events.

Anyway, it is really strange, because when you erase the events file and start the server, the server should

  • create the missing empty events file
  • open it and monitor for new events
  • wheneve a new event is written into the file (by anyone), the server detects it, read a new event and send it to the client

In your case, it seems that the server detects a new event, but read it from the erased (unlinked) file and send the event from the erased file.

— Reply to this email directly or view it on GitHub https://github.com/CESNET/libnetconf/issues/170#issuecomment-194877643.

rkrejci commented 8 years ago

great, I was almost out of ideas :) Can you name the client to know that there is such a problem?