波什用https击败了https

时间:2013-09-10 13:35:21

标签: https smack bosh

我试图通过https创建与openfire的Bosh连接。我尝试使用带有hhtps参数的BoshConfiguration为true。但是连接在远程服务器上超时。 任何人都有任何关于波什的实际例子吗?

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题。我可以通过更改JBosh库来建立连接和登录,因为那里的HttpClient使用不考虑SSL上下文。

我遵循http://www.java-samples.com/showtutorial.php?tutorialid=211中使用的方法,在subscribe()方法中进行了一些修改,返回SSLContext并在XLightWebSender.java init()方法中使用,如下所示:

public void init(final BOSHClientConfig session) {
    lock.lock();
    try {
        cfg = session;
        SSLContext context = null;
        try {
            context = this.subscribe();
        } catch (Exception e) {
            e.printStackTrace();
        }
        client = new HttpClient(context);
    } finally {
        lock.unlock();
    }
}
PS:我还在测试,并且不能保证这种解决方案适用于长期生活连接。