Problem receiving published item once logout and login again

Hi there

I have encountered a problem where item is not published successfully to subscribers end once I logged out and logged in again. It works fine if I make login on newly created node but stopped working when I subscribed to existing node. If i delete the node and start over again, it works fine.

I am wondering, do i have to delete and create node everytime i make login to publish items on the node?

Of course not. Unfortunately, there isn’t enough information here to tell what you are doing wrong. Some code samples might help.

Thanks for your response.

I would like to know, do i need to subscribe every time I make login or my subscription will be persisted when i make subscription at the initial for which i don’t have to make subscription again.

Is it necessary to unsubscribe when close the connection?

As you have mentioned about some sample code, will javascript code work as on client side i am using javascript to handle and manage subscription to pubsub node?

This is client client side of xmpp connection. I am not sure whether it will make any sense to you. Here i have setup a callback for the event, if there is any new message, on event method will be invoked.

// connection and service value are as follows

CJ.app.conn: null,

CJ.app.service: ‘pubsub.mammoth.local’,

CJ.app. node: ‘CJNode’,

CJ.app.NS_DATA_FORMS: “jabber:x:data”,

CJ.app.NS_PUBSUB: “http://jabber.org/protocol/pubsub”,

CJ.app.NS_PUBSUB_OWNER: “http://jabber.org/protocol/pubsub#owner”,

CJ.app.NS_PUBSUB_ERRORS: “http://jabber.org/protocol/pubsub#errors”,

CJ.app.NS_PUBSUB_NODE_CONFIG: “http://jabber.org/protocol/pubsub#node_config”,

Ext.define(‘CJ.view.MainList’, {

extend: ‘Ext.dataview.DataView’,

xtype : ‘mainlist’,

config: {

cls: ‘categories-list’,

flex: 2

},

initialize: function() {

if (CJ != null) {

this.connected();

}

},

connected: function() {

// send negative presence send we’re not a chat client

// CJ.connection.send(‘priority -1’);

CJ.app.conn.send($pres().c(“priority”).t("-1"));

if (CJ.app.node.length > 0) {

// first, set up a callback for the events

CJ.app.conn.addHandler( this.on_event,

null, “message”, null, null, CJ.app.service);

// now subscribe

var subiq = $iq({to: CJ.app.service, type: “set”})

.c(‘pubsub’, {xmlns: CJ.app.NS_PUBSUB})

.c(‘subscribe’, {node: CJ.app.node, jid: CJ.app.conn.jid});

CJ.app.conn.sendIQ(subiq, this.subscribed, this.subscribe_error);

CJ.app.conn.flush();

}

},

configured: function (iq) {

//$(document).trigger(“broadcast_started”);

},

configure_error: function (iq) {

CJ.app.show_error("CJ configuration failed with " +

CJ.app.make_error_from_iq(iq));

},

on_event: function(msg) {

if ($(msg).find(‘x’).length > 0) {

var message = $(msg).find(‘field[var=“message”] value’).text();

alert(message);

} else if ($(msg).find(‘delete[node="’ + CJ.app.node + ‘"]’)

.length > 0) {

}

return true;

},

// subscription callbacks

subscribed: function(iq) {

//alert(‘subscribed successfully’);

},

subscribe_error: function(iq) {

this.show_error('Subscription falied with '+ this.make_error_from_iq(iq));

},

show_error: function (msg) {

CJ.app.conn.disconnect();

CJ.app.conn = null;

alert(msg);

},

// error handling helpers

make_error_from_iq: function (iq) {

var error = $(iq)

.find(’*[xmlns="’ + Strophe.NS.STANZAS + ‘"]’)

.get(0).tagName;

var pubsub_error = $(iq)

.find(’*[xmlns="’ + CJ.app.NS_PUBSUB_ERRORS + ‘"]’);

if (pubsub_error.length > 0) {

error = error + “/” + pubsub_error.get(0).tagName;

}

return error;

},

showOverlay : function() {

}

});

This code will work fine if I make fresh login on newly created node. Surprisingly it works on existing node as well but sometimes stopped working suddenly. Does it mean the xmpp loses connection? it seems to be not reliable.

I am using strophe.js javascript library to add further information on it.

No, you do not need to subscribe every time, unless you deleted your subscription before disonnecting.

I don’t know javascript, but hopefully someone else will be able to help you.