Subject: Intermittent failures in node creation
Hello,
We are using Matrix .NET library to publish events from a back end service.
Here is roughly what we try to do, sample working code attached.
Essentially we login and on the login call back we try to create a new node. What we find is if we attempt to create a node on call back it doesn't work. Essentially the Task returned by _pubSubManager.CreateNodeAsync(_pubSubJid, nodeName, nodeConfigurations) never seem to complete and so, our "ContinueWith" task never gets executed.
So, we made a minor change. Instead of attempting to create the node directly within the call back, we now try to create a new task from within the call back and introduce some delay before the createnode call.
This seems to work most of the time - but fails for about 10% of the attempts.
So, the questions are:
1. Is this the expected behaviour?
2. If so, how do I know when the xmppclient is ready for creation of nodes? How long do I need to wait? Are there any call back or messages to indicate that everything is now ready?
3. Is _xmppClient library thread safe? Can I use it from multiple threads without any side effects? e.g. If I try to create two different nodes from two different threads using the same XmppClient and PubsubManager, will it work fine?
4. Is this library suitable for use in an server environment where may different threads are attempting to process and publish events concurrently?
Appreciate your help,
Gireesh
We are using Matrix .NET library to publish events from a back end service.
Here is roughly what we try to do, sample working code attached.
- public void Test()
- {
- _xmppClient.SetUsername("user2");
- _xmppClient.Password = "pass123";
- _xmppClient.SetXmppDomain("somedomain.com");
- _xmppClient.Transport = Matrix.Net.Transport.Bosh;
- _xmppClient.OnError += _xmppClient_OnError;
- try
- {
- _xmppClient.Open();
- }
- catch (Exception e)
- {
- throw e;
- }
- }
- public void CreateNode()
- {
- // code for creating node
- }
Essentially we login and on the login call back we try to create a new node. What we find is if we attempt to create a node on call back it doesn't work. Essentially the Task returned by _pubSubManager.CreateNodeAsync(_pubSubJid, nodeName, nodeConfigurations) never seem to complete and so, our "ContinueWith" task never gets executed.
So, we made a minor change. Instead of attempting to create the node directly within the call back, we now try to create a new task from within the call back and introduce some delay before the createnode call.
- =>
- {
- Console.WriteLine("OnLoginCallBack");
- Task.Factory.StartNew(()
- =>
- {
- Thread.Sleep(1000);
- CreateNode("somenodetobecreated10");
- });
- });
This seems to work most of the time - but fails for about 10% of the attempts.
So, the questions are:
1. Is this the expected behaviour?
2. If so, how do I know when the xmppclient is ready for creation of nodes? How long do I need to wait? Are there any call back or messages to indicate that everything is now ready?
3. Is _xmppClient library thread safe? Can I use it from multiple threads without any side effects? e.g. If I try to create two different nodes from two different threads using the same XmppClient and PubsubManager, will it work fine?
4. Is this library suitable for use in an server environment where may different threads are attempting to process and publish events concurrently?
Appreciate your help,
Gireesh
The author has attached one file to this post:
TestMatrix.cs 4.6 kBytes
You have no permission to open this file.
You have no permission to open this file.
This post was edited on 2015-11-17, 22:05 by Alex.