Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
Avatar
wmorrison #1
Member since Dec 2015 · 50 posts · Location: Kingston, Jamaica
Group memberships: Members
Show profile · Link to this post
Subject: Number of Connections
Hello,
       Need some assistance with the number of connections I can create.  I have a static class that does the initialization and create the initial object.  I am able to use that object to login into my server.  However when I try to login using another object (same initialisation process as before) I am getting an error.  I even tried to setup another static class with a different name and initialized the another object.  This would give me 2 xmppclient objects.  When I try to login with the second client object I am getting an error "Exception has been thrown by the target of an invocation."

What I am doing wrong?

Regards
Will
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
would need your full stacktrace, also of the inner exception when available.
Why do you need multiple connection? Usually in XMPP a client has one long running connection which is shared in all modules of your code. You would only need multiple connections if you want to login multiple different users in your code at the same time.

Alex
Avatar
wmorrison #3
Member since Dec 2015 · 50 posts · Location: Kingston, Jamaica
Group memberships: Members
Show profile · Link to this post
Hi Alex,
     Thanks for the quick response.  I may need 2 logons for the prototype app I working on.  One for the user to use while the other is for services.  The first logon works and its onlogon event setup the other xmppclient object.  The second xmppclient object onlogon event work fine it seem but then it then goes to onError event.  On my ejabberd server I am seeing the first xmppclient object signed on without issue however the second xmppclient object is not.  Its authenticated but session never opened.

My Button Click event:
  1.   _xmppClient.OnLogin += xmppClient_OnLogin;
  2.   _xmppClient.OnError += xmppClient_OnError;
  3.   _xmppClient.Username = userList[0].JID;
  4.   _xmppClient.Password = userList[0].Password;
  5.   _xmppClient.XmppDomain = listSystemSettings[0].DomainName;
  6.   _xmppClient.Hostname = listSystemSettings[0].Host;
  7.   _xmppClient.Resource = "Individual";
  8.   _xmppClient.OnAuthError += _xmppClient_OnAuthError;
  9.   _xmppClient.Open();
  10.  
  11. OnLogon Event (for XmppClient Object):
  12.    var systemSettingsCrud1 = new CRUDRepository<SystemSettings>();
  13.    var listSystemSettings = systemSettingsCrud1.GetByQuery("Select * from SystemSettings", _dbConnection);
  14.  
  15.    _xmppAdmin.OnLogin += xmppAdmin_OnLogin;
  16.    _xmppAdmin.OnError += xmppAdmin_OnError;
  17.    _xmppAdmin.Username = listSystemSettings[0].JIDAdminId;
  18.    _xmppAdmin.Password = listSystemSettings[0].JIDAdminPassword;
  19.    _xmppAdmin.XmppDomain = listSystemSettings[0].DomainName;
  20.    _xmppAdmin.Hostname = listSystemSettings[0].Host;
  21.    _xmppAdmin.Open();

xmppAdmin onLogon Event:
          No problem here

xmppAdmin onError Event:
 var msg = e.Exception.Message; <---This is where the stacktrace was taken


The stacktrace is as follow:

Inner Exception:
"Object reference not set to an instance of an object"
"  at Prototype.Droid.MainActivity.xmppAdmin_OnLogin (System.Object sender, Matrix.EventArgs e) [0x00001] in c:\\C# Projects\\Apps Dev\\Your Messengar App\\ServerApps\\Prototype\\MessagePrototype\\Prototype.Droid\\MainActivity.cs:202 \n 
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)\n 
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in /Users/builder/data/lanes/2512/d3008455/source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:295 "


"Exception has been thrown by the target of an invocation."
"  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00050] in /Users/builder/data/lanes/2512/d3008455/source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:303 \n 
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /Users/builder/data/lanes/2512/d3008455/source/mono/external/referencesource/mscorlib/system/reflection/methodbase.cs:277 \n 
at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x00107] in /Users/builder/data/lanes/2512/d3008455/source/mono/mcs/class/corlib/System/Delegate.cs:471 \n 
at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x0000b] in /Users/builder/data/lanes/2512/d3008455/source/mono/mcs/class/corlib/System/MulticastDelegate.cs:66 \n 
at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in /Users/builder/data/lanes/2512/d3008455/source/mono/mcs/class/corlib/System/Delegate.cs:416 \n 
at Matrix.XmppStream.DoRaiseEvent (System.Delegate del, System.Object[] args) [0x00000] in <filename unknown>:0 \n 
at Matrix.XmppStream.DoRaiseEvent (System.Delegate del, System.Object arg1, Matrix.EventArgs arg2) [0x00011] in <filename unknown>:0 \n 
at Matrix.XmppStream.FireOnLogin (System.Object sender) [0x0001c] in <filename unknown>:0 \n  at Matrix.XmppStream.FireOnLogin () [0x00000] in <filename unknown>:0 \n 
at Matrix.Xmpp.Client.XmppClient.SaslHandlerOnSaslSuccess (System.Object sender, Matrix.EventArgs e) [0x0000c] in <filename unknown>:0 \n 
at Matrix.SaslHandler.XmppStreamParser_OnStreamElement (System.Object sender, Matrix.StanzaEventArgs e) [0x00029] in <filename unknown>:0 \n 
at (wrapper delegate-invoke) System.EventHandler`1[Matrix.StanzaEventArgs]:invoke_void_object_TEventArgs (object,Matrix.StanzaEventArgs)\n 
at Matrix.Xml.XmppStreamParser.DoRaiseOnStreamElement (Matrix.Xml.XmppXElement el) [0x00015] in <filename unknown>:0 "

Hopes this helps....

Will
This post was edited on 2015-12-19, 10:33 by Alex.
Avatar
wmorrison #4
Member since Dec 2015 · 50 posts · Location: Kingston, Jamaica
Group memberships: Members
Show profile · Link to this post
Hi Alex,
       I fixed the issue.  Upon following your advise on the stack trace I found the null object reference.  All is well.  Thank you.

I have another question:
Since after login on there is no way to check the status of the session, how can I check the status of the object before using it?

Will
Avatar
Alex #5
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by wmorrison:
I fixed the issue.  Upon following your advise on the stack trace I found the null object reference.  All is well.  Thank you.

when there is no try catch in your code which gets invoked from MatriX (events) then the exception of course goes up the stack to MatriX. This is where we catch exceptions in your code then and forward them in the OnError event back to you.

Quote by wmorrison:
I have another question:
Since after login on there is no way to check the status of the session, how can I check the status of the object before using it?

MatriX is event based. So watch all the events. If it fails you should get an OnError, if not OnTls, Onlogin, OnBind, OnRoster*, OnPresense. When you get the first OnPresence event your session is ready. Its alive until you get an OnClose event.

Alex
Avatar
wmorrison #6
Member since Dec 2015 · 50 posts · Location: Kingston, Jamaica
Group memberships: Members
Show profile · Link to this post
Thanks for the good advise.  I will check the relevant events every time to do some task with the XMPPClient object.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters: