how to use strophe.js function attach(jid,sid,rid,callback) to connect tigase service

lin jiafu
Added over 1 year ago

i use jaxmpp3.1.5 jar and login to got sid and rid, then i put the sid and rid to the strophe.js function attach(jid,sid,rid,callback),but it return those code 8(ATTACHED),2(CONNFAIL),6(DISCONNECTED) all the time, any wrong with my way to got the sid and rid? my code is :

import tigase.jaxmpp.core.client.JaxmppCore.LoggedInHandler;

import tigase.jaxmpp.core.client.SessionObject;

import tigase.jaxmpp.core.client.exceptions.JaxmppException;

import tigase.jaxmpp.j2se.ConnectionConfiguration.ConnectionType;

import tigase.jaxmpp.j2se.Jaxmpp;

public class Test4 {

public static void main(String[] args) {

final Jaxmpp jaxmpp = new Jaxmpp();







jaxmpp.getEventBus().addHandler(LoggedInHandler.LoggedInEvent.class, new LoggedInHandler() {


        public void onLoggedIn(SessionObject sessionObject) {

            System.out.println("SID:" + sessionObject.getProperty("BOSH#SID_KEY"));

            System.out.println("RID:" + sessionObject.getProperty("BOSH#RID_KEY"));



try {

        System.out.println("Loging in...");


} catch (final JaxmppException e) {





if it is wrong ,how to Moving authentication to server-side and Maintaining session between page changes, thanks!

Replies (6)

Added by Andrzej Wójcik IoT 1 CloudTigaseTeam over 1 year ago

XMPP specification states how XMPP servers should behave and Tigase XMPP Server is following this specification in term of authentication. Due to that XMPP clients are required to authenticate each connection they made, so it is not possible to authenticate and maintain session on a server side as it is done in HTTP servers.

In Jaxmpp we created custom GWTSessionObject class which can be retrieved from Jaxmpp instance using getSessionObject() in GWT application. This class has 2 methods serialize() and restore(String) which can be used to store session credentials and data before page reload and restore them after. This with Stream Management - Resumption feature allows you to maintain session between page refreshes.

I do not know what you want to achieve by moving session from Jaxmpp to Strophe.

Added by lin jiafu over 1 year ago

thanks Andrzej Wójcik,i want to solve the problem like the page desrcibe:,would you have any suggestion? i foud this problem confuse many people, and it not solve yet. thanks angain.

Added by Andrzej Wójcik IoT 1 CloudTigaseTeam over 1 year ago

I see that a solution of one problem is to use prebinding and this is supported by Tigase XMPP Server, see

As for reconnection of a stream on a page refresh, it is tricky for BOSH. We have support in our client library and in Tigase.IM web client to handle page refreshes but to do that we are using StreamManagement - Resumption for WebSocket-based connections and SessionStorage to pass credentials/authentication parameters between pages.

Added by lin jiafu over 1 year ago

thanks Andrzej Wójcik, i use that solution,but it retun like this



  <var>Script result</var>


  <value>Script finished with no errors but returned no results.</value>


all the time ,i change the account and try again, it does not return the right result, this is my param:














is i lose any config in

Added by Andrzej Wójcik IoT 1 CloudTigaseTeam over 1 year ago

This could be the result of an error on the server side. Please check your server log files.

Added by lin jiafu over 1 year ago

Really thanks for your patience.i found an error in the log:


at tigase.server.ConnectionManager.getServiceId(

at tigase.server.ConnectionManager.getServiceId(

at tigase.server.ConnectionManager.getXMPPIOService(

at tigase.server.bosh.BoshConnectionManager.getSeeOtherHostForJID(

at tigase.server.bosh.BoshSession.init(

at tigase.server.bosh.BoshConnectionManager.preBindSession(

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(

at sun.reflect.DelegatingMethodAccessorImpl.invoke(

at java.lang.reflect.Method.invoke(

at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(




at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(

at org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(

at tigase.server.script.Script.runCommand(

at tigase.server.BasicComponent.processScriptCommand(

at tigase.server.AbstractMessageReceiver$

how can i solve this exception,i see an article, the address is, but i don't konw how to solve this exception