Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
dotnetnerd #1
Member since Apr 2020 · 5 posts
Group memberships: Members
Show profile · Link to this post
Subject: Matrix vNext - Operation Timeout Error
Hello,

xmppClient object is failing to connect to Cisco Finesse and give an error - Operation Timeout Error. Below is the code snippet.  This code works fine in a console application, but same is not working from a WPF Application (4.6.1 Framework version).  Not sure if i need to add any additional reference.

  1. xmppClient = new XmppClient()
  2. {
  3.     Username = this._username,
  4.     Password = this._password,
  5.     XmppDomain = this._serverName,
  6.     HostnameResolver = new SrvNameResolver()
  7. };
  8.  
  9. xmppClient.CertificateValidator = new AlwaysAcceptCertificateValidator();
  10. this.SubscribeForSessionStateChange();
  11. this.SubcribeForMessageChange();
  12. this.SubcribeForPresenceChange();
  13.  
  14. try
  15. {
  16.     await xmppClient.ConnectAsync();
  17. }
  18. catch (Matrix.AuthenticationException ex)
  19. {
  20.     OnError.Invoke(this, ex);
  21. }
  22. catch (Exception ex)
  23. {
  24.     OnError.Invoke(this, ex);
  25. }
This post was edited 2 times, last on 2020-05-07, 11:13 by dotnetnerd.
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
try to connect in a new Task/Thread.
I assume its deadlocking on your UI Thread.

Also, you XML log would help if there is any.
dotnetnerd #3
Member since Apr 2020 · 5 posts
Group memberships: Members
Show profile · Link to this post
Thanks for quick response!

This is my current pattern On a Button Click > Intermediate Class > XMPPClient Class. from button click i am calling an intermediate class. in the intermediate class i am using Task.Run to do xmppclient.connect async.  But the Subscribe event fire only for Connected, there isnt any "binded" happening.


  1. xmppClient.XmppSessionStateObserver.Subscribe(state =>
  2. {
  3.                
  4. });

If i perform any operation in "Connected" state, I am getting "Operation Timeout" exception
This post was edited 2 times, last on 2020-05-07, 13:12 by Alex.
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
The Connected means only that the TCP/IP socket got connected. Nothing happened yet. You cannot perform any XMPP operation from the Connected state.

See also:
https://github.com/matrix-xmpp/matrix-vnext/blob/23df58e29…

  • It would help when you also post your Xml logs
  • You can also fetch the sources and debug it with your code to see where its hanging.

In WPF apps I usually use ReactiveUI and connect like this:

  1.  _connectCommand = ReactiveCommand.Create(
  2.                 () =>
  3.                 {
  4.                     this.CloseLoginModal.Execute(null);
  5.                     this.XmppService.Connect(this.Account);
  6.                 },
  7.                 null,
  8.                 RxApp.TaskpoolScheduler
  9.             );

Alex
dotnetnerd #5
Member since Apr 2020 · 5 posts
Group memberships: Members
Show profile · Link to this post
Thank You! I was able to figure it out that..
2 Issues
1) for some reason the Assembly "System.Runtime.CompilerServices.Unsafe.dll" was not copied to working folder.
2) In order to troubleshoot the issue, i changed all Async to Async.GetAwaiter which messed-up my events. Once i converted to Async, everything worked fine as expected.
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: