Subject: How to connect after failed registration
Hello,
in our environment, it is not sure whether the user account already exists when the client is launched. The registration process itself works fine, but if the account existed beforehand, it is impossible to connect to it afterwards. The xmppClient.Open() method does nothing, not even logging XML output.
I even created a registerAccount function that gets called before the regular login, using a seperate xmppClient object, also not successful:
Is this a bug in MatriX or do I need to rethink my program's logic?
Regards!
in our environment, it is not sure whether the user account already exists when the client is launched. The registration process itself works fine, but if the account existed beforehand, it is impossible to connect to it afterwards. The xmppClient.Open() method does nothing, not even logging XML output.
I even created a registerAccount function that gets called before the regular login, using a seperate xmppClient object, also not successful:
- public partial class Form1 : Form
- {
- static string serverFQDN = "localhost";
- static string thisUname = "testusername"
- static string thisPassword = "VerySecure";
- static string thisJid = thisUname + "@" + serverFQDN;
- public Form1()
- {
- InitializeComponent();
- registerClient();
- xmppClient.Password = thisPassword;
- xmppClient.Username = jidThis.User;
- xmppClient.SetXmppDomain(jidThis.Server);
- xmppClient.Open();
- private static void registerClient()
- {
- regXmppClient.Password = thisPassword;
- regXmppClient.Username = jidThis.User;
- regXmppClient.SetXmppDomain(jidThis.Server);
- regXmppClient.RegisterNewAccount = true;
- regXmppClient.OnRegisterError += new EventHandler<Matrix.Xmpp.Client.IqEventArgs> (xmppClient_OnRegisterError);
- regXmppClient.OnRegisterInformation += new EventHandler<Matrix.Xmpp.Register.RegisterEventArgs>(xmppClient_OnRegisterInformation);
- try
- {
- regXmppClient.Open();
- regXmppClient.Close();
- regXmppClient.Dispose();
- }
- }
- private static void xmppClient_OnRegister(object sender, Matrix.EventArgs e)
- {
- //Registration success
- writeLogEntry("Registration success", "xmppClient_OnRegister");
- }
- private static void xmppClient_OnRegisterError(object sender, IqEventArgs e)
- {
- //This gets called if the registration fails (e.g. account already exists)
- writeLogEntry(e.Iq.Error.ToString(), "xmppClient_OnRegisterError");
- }
- private static void xmppClient_OnRegisterInformation(object sender, Matrix.Xmpp.Register.RegisterEventArgs e)
- {
- writeLogEntry("Setting registration information", "xmppClient_OnRegisterInformation");
- e.Register.XData.RemoveAll();
- e.Register.XData.Remove();
- e.Register.Password = thisPassword;
- e.Register.Username = jidThis.User;
- }
- private static void writeLog(String fname, String msg, String type)
- {
- DateTime dt = DateTime.Now;
- String timeStamp = dt.ToString("yyyyMMdd_HHmmss");
- String fileName = fname+"_" + dt.ToString("yyyyMMdd");
- String filePath = System.IO.Path.GetTempPath();
- String fullPath = filePath + @"\" + fileName + ".log";
- String text = "[" + timeStamp + " " + type + "] " + msg + Environment.NewLine;
- if (File.Exists(fullPath))
- {
- File.AppendAllText(fullPath, text);
- }
- else
- {
- File.WriteAllText(fullPath, text);
- }
- }
- private static void writeLogEntry(String msg, String type)
- {
- writeLog("client",msg,type);
- }
- private static void writeLogXml(String msg)
- {
- writeLog("clientxml", msg, "");
- }
- private static void writeLogRegXml(String msg)
- {
- writeLog("clientregxml", msg, "");
- }
- private static void XmppClientOnSendXml(object sender, TextEventArgs e)
- {
- writeLogXml("SEND: " + e.Text);
- }
- private static void XmppClientOnReceiveXml(object sender, TextEventArgs e)
- {
- writeLogXml("RECV: " + e.Text);
- }
- private static void RegXmppClientOnSendXml(object sender, TextEventArgs e)
- {
- writeLogRegXml("SEND: " + e.Text);
- }
- private static void RegXmppClientOnReceiveXml(object sender, TextEventArgs e)
- {
- writeLogRegXml("RECV: " + e.Text);
- }
- }}
Is this a bug in MatriX or do I need to rethink my program's logic?
Regards!
This post was edited on 2016-10-06, 12:42 by Alex.