How to connect XMPP bosh server using java smack library?

前端 未结 3 611
刺人心
刺人心 2021-01-13 22:14

I have working xmpp client on webapp using strophe.js ,as per my use case scenario i have to switch to different pages rapidly

Current approach is not secure as ji

3条回答
  •  [愿得一人]
    2021-01-13 22:53

    I had a similar problem. I donwload all the smack github I import smack.jar from /lib/ and add the 3 java files from /src/main/java/org/jivesoftware/smack/

    I tried to fix it by importing smack-bosh-3.2.2-jar-with-dependencies.jar from /target/. I don't know why this diddn't work.

    Finally, I read here that you need to download all the dependencies libraries : jbosh-0.6.0.jar xlightweb-2.5.jar xSocket-2.4.6.jar xpp3-1.1.3.3.jar dom4j-1.6.1.jar

    So I used smack.jar from /lib/ with all thoses libraries and this problem was solved.

    As i said in comments, you need after to retreive RID. I used jbosh sources and add following lines :

    In com.kenai.jbosh.BOSHClient class
    //I introduced a new property
    private Long rid;
    
    //commented the following code
    //long rid = requestIDSeq.getNextRID();
    //and at that place added
    this.rid = requestIDSeq.getNextRID();
    
    //and finally added a new getter for rid
    public Long getRid() {
        return rid;}
    

    Then in smack-bosh :

    In BOSHConnection.java
    public Long getRid() {
        return client.getRid();}
    public String getSid() {
        return sessionID;}
    

    Now I'm blocked cause my session is disconected. According to my openFire logs, it's because of overactivity. So I'm looking for a solution to reduce the number of presence messages.

提交回复
热议问题