Not logged in. · Lost password · Register
Forum: MatriX RSS
rperetz #1
Member since Mar 2021 · 4 posts
Group memberships: Members
Show profile · Link to this post
Subject: Getting ClientSocket Connection request failed from sample code I downloaded
I got your latest demo code, the code go the OnError method with an Errror:
ClientSocket Connection request failed
what am I doing wrong?



  1. using System;
  2. using Matrix.Xmpp;
  3. using Matrix.Xmpp.Client;
  4.  
  5. namespace SendMessage
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             var xmppClient = new XmppClient
  12.                                  {
  13.                                      XmppDomain = "traffictech.lan",
  14.                                      Username = "masjab",
  15.                                      Password = "SomePassword",
  16.                                      Port = 1080
  17.                                 };
  18.  
  19.             xmppClient.OnError += new System.EventHandler<Matrix.ExceptionEventArgs>(xmppClient_OnError);
  20.  
  21.             xmppClient.OnRosterEnd += delegate
  22.                                           {
  23.                                               xmppClient.Send(new Message
  24.                                                                   {
  25.                                                                       To = "perron@traffictech.lan",
  26.                                                                       Type = MessageType.chat,
  27.                                                                       Body = "Hello World"
  28.                                                                   });
  29.  
  30.                                           };
  31.             xmppClient.Open();
  32.            
  33.             Console.WriteLine("Press return key to exit the application");
  34.             Console.ReadLine();
  35.  
  36.             xmppClient.Close();
  37.  
  38.             void xmppClient_OnError(object sender, Matrix.ExceptionEventArgs e)
  39.             {
  40.                
  41.                 Console.WriteLine("xmppClient_OnError Fired " + e.Exception.ToString());
  42.             }
  43.            
  44.  
  45.         }
  46.     }
  47. }

the debug trace shows this:
[78476] InitSideBySide failed create an activation context. Error: 1814
[76588] Client Verbose: 0 :
[76588] Common model for csharp intellisense-members is cached.
[76588] Client Verbose: 0 :
[76588] Attempting to get team models for csharp intellisense-members at C:\Work\JabberMatrixSDKNET2\MatriX\samples\csharp\SendMessage\.
[76588] Client Verbose: 0 :
[76588] The path C:\Work\JabberMatrixSDKNET2\MatriX\samples\csharp\SendMessage\ does not belong to a Git repository, and cannot have any team models attached to it.
[76588] Client Verbose: 0 :
[76588] Common model for csharp intellisense-arguments is cached.
[24924] InitSideBySide failed create an activation context. Error: 1814
The author has attached one file to this post:
dll.tif 531.4 kBytes
You have no permission to open this file.
This post was edited on 2021-03-27, 09:07 by Alex.
Edit reason: This is the dll version
Avatar
Alex #2
Member since Feb 2003 · 4433 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
MatriX cannot connect to your server traffictech.lan on port 1080.

  • Are you sure the port is correct?
  • Do you have SRV records set on this domain?
  • When there are no SRV records set does DNS resolve the IP address correct?

See also here in the docs how you can disable SRV resolving and manual specify host or IP and port for development purposes:
https://www.ag-software.net/matrix-xmpp-sdk/matrix-develop…

Alex
rperetz #3
Member since Mar 2021 · 4 posts
Group memberships: Members
Show profile · Link to this post
Made changes to the connections, use this code below now:

  1. using System;
  2. using Matrix.Xmpp;
  3. using Matrix.Xmpp.Client;
  4.  
  5. namespace SendMessage
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.            
  12.             var xmppClient = new XmppClient
  13.                                  {
  14.                                      XmppDomain = "traffictech.lan",
  15.                                      Username = "masjab@traffictech.lan",
  16.                                      Password = "some password",
  17.                                      Hostname = "10.64.32.14",
  18.                                      ResolveSrvRecords = true,
  19.                                     Port = 1080
  20.             };
  21.            
  22.  
  23.            
  24.  
  25.             xmppClient.OnError += new System.EventHandler<Matrix.ExceptionEventArgs>(xmppClient_OnError);
  26.  
  27.             xmppClient.OnRosterEnd += delegate
  28.                                           {
  29.                                               xmppClient.Send(new Message
  30.                                                                   {
  31.                                                                       To = "perron@traffictech.lan",
  32.                                                                       Type = MessageType.chat,
  33.                                                                       Body = "Hello World"
  34.                                                                   });
  35.  
  36.                                           };
  37.             xmppClient.Open();
  38.            
  39.             Console.WriteLine("Press return key to exit the application");
  40.             Console.ReadLine();
  41.  
  42.             xmppClient.Close();
  43.  
  44.             void xmppClient_OnError(object sender, Matrix.ExceptionEventArgs e)
  45.             {
  46.                
  47.                 Console.WriteLine("xmppClient_OnError Fired " + e.Exception.ToString());
  48.             }
  49.            
  50.  
  51.         }
  52.     }
  53. }



Now I am getting this error message.
xmppClient_OnError Fired System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 10.64.32.14:1080

As a side note, it seem that this connection is working fine for the PresenceManager object, I seem to get XML data from there.
but I can't send messages yet.
Can you send messages using the PresenceManager class (I don't think so).
This post was edited on 2021-03-29, 21:55 by Alex.
Avatar
Alex #4
Member since Feb 2003 · 4433 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
your code above still has ResolveSrvRecords = true
When ResolveSrvRecords is true then your hostname and IP address is settings are ignored. Set it to false please when you want to specify it manual.

Your username is also wrong. The username is everything before the @, which is your xmpp domain.

Quote by rperetz:
As a side note, it seem that this connection is working fine for the PresenceManager object, I seem to get XML data from there.
but I can't send messages yet.
Can you send messages using the PresenceManager class (I don't think so).

This is impossible when you get socket errors and no connection.

Alex
rperetz #5
Member since Mar 2021 · 4 posts
Group memberships: Members
Show profile · Link to this post
I got it to work.
did your changes and changed to the correct port number.

  1. var xmppClient = new XmppClient
  2. {
  3.     XmppDomain = "traffictech.lan",
  4.     Username = "masjab",
  5.     Password = "somepass",
  6.     Hostname = "10.64.32.14",
  7.     ResolveSrvRecords = false,
  8.     Port = 5222
  9. };
rperetz #6
Member since Mar 2021 · 4 posts
Group memberships: Members
Show profile · Link to this post
I am thinking of using this as a server side service to send messages from a master user to any user.
wrap this code in WEB.API Rest service with a method that looks like
SendXMPPMessage(String ToUserName, String Message)

what do you think?
Avatar
Alex #7
Member since Feb 2003 · 4433 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I don't know your exact use case. But I see no issues with that.
But be aware that many XMPP servers have REST APIs build in already for something like that.

Alex
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:
Forum: MatriX RSS