Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
Michael Trinkies #1
Member since Feb 2017 · 6 posts
Group memberships: Members
Show profile · Link to this post
Subject: Message is not send correctly
Hello guys I'm writing an ChatServer and I'm got very far on this.
I've written several clients which can correctly connect and correctly send messages .

No I've written a small ChatClient class which can connect to the ChatServer and send a message by given arguments.
So, now if I wan't to send the message the server receives each Tag in the XML structure so I've debbuged by subscribing to the "OnSendXml" event. The clients sends the message correctly:

  1. <message xmlns="jabber:server" id="5341abc9-f711-4b18-9993-157c3b54c909" type="groupchat" from="{correct user jid}" to="{correct user jid}">
  2.  
  3. <body>Test</body>
  4.  
  5. <delay xmlns="urn:xmpp:delay" stamp="2017-07-28T07:22:17.507Z"/>
  6.  
  7. </message>

BUT: The Server only received

  1. <body>Test</body>

So why is this happening on other clients I do the equal same. I'm not able to find my issue.
I hope you can help me.

Here is the code from my client class

  1. public class ChatClient
  2. {
  3.     public string CurrentUserJid{ get; }
  4.     private XmppClient XmppClient { get; }
  5.     public bool LoggedIn { get; set; }
  6.     public string Email { get; set; }
  7.     public string LoginName { get; set; }
  8.     public event EventHandler OnLoggedIn;
  9.     public event EventHandler OnError;
  10.  
  11.     //need email & loginName for non identity login
  12.     public ChatClient(string server, int port, string loginName, string email, string passowrd)
  13.     {
  14.         Email = email;
  15.         LoginName = loginName;
  16.         CurrentUserJid = new Jid(LoginName, Environment.UserDomainName, loginName);
  17.         XmppClient = new XmppClient();
  18.         XmppClient.SetUsername(LoginName);
  19.         XmppClient.SetXmppDomain(Environment.UserDomainName);
  20.         XmppClient.Port = port;
  21.         XmppClient.StartTls = true;
  22.         XmppClient.Hostname = server;
  23.         XmppClient.ResolveSrvRecords = false;
  24.         XmppClient.Resource = LoginName;
  25.         XmppClient.AutoRoster = false;
  26.         XmppClient.AutoPresence = true;
  27.         XmppClient.Password = passowrd;
  28.         XmppClient.OnSendBody += (sender, args) =>
  29.         {
  30.  
  31.         };
  32.         XmppClient.OnSendXml += (sender, args) =>
  33.         {
  34.  
  35.         };
  36.  
  37.         XmppClient.OnLogin += (sender, args) =>
  38.         {
  39.             LoggedIn = true;
  40.             OnLoggedIn?.Invoke(this, null);
  41.         };
  42.         XmppClient.OnError += (sender, args) =>
  43.         {
  44.             OnError?.Invoke(this, null);
  45.         };
  46.  
  47.     }
  48.  
  49.     public void Login()
  50.     {
  51.         XmppClient.Open();
  52.     }
  53.  
  54.     public bool SendMessage(string content, string to, MessageType messageType, DateTime sendTime)
  55.     {
  56.         if (!LoggedIn) return false;
  57.         var msg = new Matrix.Xmpp.Server.Message(to.ToJid(), Email.ToJid(),messageType, content);
  58.         msg.Type = messageType;
  59.         msg.Id = Guid.NewGuid().ToString();
  60.         msg.Delay = new Delay(sendTime);
  61.         XmppClient.Send(msg);
  62.         return true;
  63.     }
  64. }

Additional: I'm using the StreamParser on the server side to parse received socket data, on other clients the "Message" Tag is correctly parsed

Best Regards
Michael
This post was edited 2 times, last on 2017-07-28, 19:15 by Alex.
Avatar
Alex #2
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
without seeing your server side logs and code its hard to find the problem.
Are you using the StreamParser correctly? Especially in regards to stream resets?
Avatar
Michael Trinkies #3
Member since Feb 2017 · 6 posts
Group memberships: Members
Show profile · Link to this post
So I fixed the issue. My problem was, that I'm sending the message to early. I'm not waited for the client to bind and sending the message before the presence was send, so the message was not send correctly
Avatar
Alex #4
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Great to hear it works now
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