【问题标题】:SASL XMPP authentication fails with <not - authorized>SASL XMPP 身份验证失败并显示 <not - authorized>
【发布时间】:2017-05-09 05:01:27
【问题描述】:

我是 Unity 的初学者,第一次在 Unity 中实现 XMPP,但无法与服务器建立连接。 以下是错误日志:

 <stream:stream to='192.168.1.225' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>

 <stream:stream xmlns:stream="http://etherx.jabber.org/streams" from="daydate" xml:lang="en" id="80mu0xgew1" version="1.0" >

 <stream:features xmlns:stream="http://etherx.jabber.org/streams"><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" /><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism><mechanism>SCRAM-SHA-1</mechanism><mechanism>CRAM-MD5</mechanism><mechanism>DIGEST-MD5</mechanism></mechanisms><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression><auth xmlns="http://jabber.org/features/iq-auth" /><register xmlns="http://jabber.org/features/iq-register" /></stream:features>

 <starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" />

 <proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls" />

 <stream:stream to='192.168.1.225' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en'>

 <stream:stream xmlns:stream="http://etherx.jabber.org/streams" from="daydate" xml:lang="en" id="80mu0xgew1" version="1.0" >

 <stream:features xmlns:stream="http://etherx.jabber.org/streams"><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism><mechanism>ANONYMOUS</mechanism><mechanism>SCRAM-SHA-1</mechanism><mechanism>CRAM-MD5</mechanism><mechanism>DIGEST-MD5</mechanism></mechanisms><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression><auth xmlns="http://jabber.org/features/iq-auth" /><register xmlns="http://jabber.org/features/iq-register" /></stream:features>

 <auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="DIGEST-MD5" />

 <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">cmVhbG09ImRheWRhdGUiLG5vbmNlPSJ0anpIMkhxMGJnRC9hVVdmNHAvZTNGaWdFYVpod0pHRGdzdkkrYXBPIixxb3A9ImF1dGgiLGNoYXJzZXQ9dXRmLTgsYWxnb3JpdGhtPW1kNS1zZXNz</challenge>

 <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dXNlcm5hbWU9InNhZ2FyIixyZWFsbT0iZGF5ZGF0ZSIsbm9uY2U9InRqekgySHEwYmdEL2FVV2Y0cC9lM0ZpZ0VhWmh3SkdEZ3N2SSthcE8iLGNub25jZT0iZjdmZmY5YjBmZDEwZGQ4ZGMxYWVhMzg2MDM2OTJmMzNkNDdjNGFlZWNhMTcwNzYwYzlhNmZlZjQwZjAyMmZmMCIsbmM9MDAwMDAwMDEscW9wPWF1dGgsZGlnZXN0LXVyaT0ieG1wcC8xOTIuMTY4LjEuMjI1IixjaGFyc2V0PXV0Zi04LHJlc3BvbnNlPTJkYWMyMDMxMDA2NDIxM2E3ZDBlOTFkMDUzYzQ1NjYx</response>

 <failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized /></failure>

 <failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized /></failure>

 </stream:stream>

下面是与服务器建立连接的代码:

void Start () {


    connection = new JUN.Connection();

    connection.Server = "192.168.1.225"; 
    connection.Port = 5222;
    connection.Username = "username";  //Without @domainName
    connection.Password = "password";

    connection.AutoRoster = true;
    connection.AutoAgents = false;
    connection.AutoPresence = true;
    connection.AutoResolveConnectServer = false;

    connection.SocketConnectionType = SocketConnectionType.Direct;

    connection.OnReadXml += new XmlHandler(OnReadXml);
    connection.OnWriteXml += new XmlHandler(OnWriteXml);
    connection.OnLogin += delegate (object sender) { queue.Enqueue(() => OnLogin(sender)); };
    connection.OnClose += delegate (object sender) { queue.Enqueue(() => OnClose(sender)); };
    connection.OnError += new ErrorHandler(OnError);
    connection.OnPresence += delegate (object sender, Presence pres) { queue.Enqueue(() => OnPresence(sender, pres)); };
    connection.OnMessage += delegate (object sender, Message msg) { queue.Enqueue(() => OnMessage(sender, msg)); };
    connection.OnAuthError += new XMPPElementHandler(OnAuthError);
    connection.OnSocketError += new ErrorHandler(OnSocketError);
    connection.OnStreamError += new XMPPElementHandler(OnStreamError);

    connection.OnConnectionStateChanged += delegate (object sender, ConnectionState state) { queue.Enqueue(() => OnConnectionStateChanged(sender, state)); };
    connection.Open ();

}

我正面临这个问题,并浏览了许多具有相同问题的文档,但没有得到任何解决方案。 我正在使用 Openfire 服务器。

请帮帮我。

【问题讨论】:

    标签: c# unity3d xmpp monodevelop openfire


    【解决方案1】:

    您的 XMPP 域是 daydate,而不是您在服务器属性中设置的 ip。 将服务器设置为 daydate 并将服务器连接到您的 ip。

    为您的服务器设置正确的 dns 和 SRV 记录会更容易。 XMPP 域是 SASL 身份验证的一部分,除了用户名和密码。

    【讨论】:

    • 然后请添加您的新日志,并验证用户名和密码是否正确。
    • 代码可以在实时服务器上正常工作,但不能在我的机器上创建的本地服务器上工作。
    • "daydate" 必须是“实时”服务器的名称,但您的本地服务器有另一个,只需在 openfire 管理面板上检查即可
    猜你喜欢
    • 1970-01-01
    • 2014-10-31
    • 1970-01-01
    • 2016-08-20
    • 1970-01-01
    • 2013-03-09
    • 1970-01-01
    • 2021-11-23
    • 1970-01-01
    相关资源
    最近更新 更多