【问题标题】:Stuck when connect to server when using xmppFramework使用 xmppFramework 连接到服务器时卡住
【发布时间】:2018-12-02 10:12:32
【问题描述】:

我从 xmppFramework 开始,使用 iOS 和本地 ejabberd 服务器(在“localhost:5280”上运行)。我使用“用户名:admin,密码:admin”登录 ejabberd 服务器

我正确检查了我的代码并添加了委托“XMPPStreamDelegate”。 我遇到的问题是我的代码调用了委托函数“xmppStreamWillConnect”,但它没有调用“xmppStreamDidConnect”。

一般来说,什么可能导致这个问题?

我的代码:

func connect() {
    if !self.xmppStream.isDisconnected() {
        return
    }
    self.xmppStream.hostName = "localhost:5280"
    self.xmppStream.myJID = XMPPJID(string:"admin@localhost")
    try! self.xmppStream.connect(withTimeout: 10)
    if self.xmppStream.isConnected(){
        print(true)
    }
    self.xmppStream.startTLSPolicy = XMPPStreamStartTLSPolicy.required
    self.xmppStream.supportsStartTLS()
    print("ok")
}

func xmppStreamWillConnect(_ sender: XMPPStream!) {
    print("will connect ")
}
func xmppStreamDidConnect(_ stream: XMPPStream!) {
    print("Stream: Connected")
    try! stream.authenticate(withPassword: self.password)
}

打印结果是: 行 将连接

【问题讨论】:

    标签: swift ejabberd xmppframework


    【解决方案1】:

    如果你做本地主机,它肯定不会工作。 模拟器将在本地主机上运行,​​您不能在同一个本地主机上同时运行。

    【讨论】:

    • 谢谢。我试图在本地连接它,当我将它更改为服务器时它可以正常工作。
    猜你喜欢
    • 1970-01-01
    • 2013-07-07
    • 2015-05-03
    • 1970-01-01
    • 1970-01-01
    • 2012-04-24
    • 2014-09-09
    • 2015-01-01
    • 1970-01-01
    相关资源
    最近更新 更多