I’m having problems to publish an event to a PubSub service. I'm using Smack Java library on application side and eJabberd 1711 on the server side (I also tried eJabberd server 1701 on an other machine).
I successfully create node on eJabberd server with deliver_payloads and persist_items set to false, as it is required configuration by XEP-0060 specification and everything about the node is ok which I can confirm by reading node configuration:
[(FORM_TYPE:http://jabber.org/protocol/pubsub#node_config) (pubsub#deliver_payloads:0) (pubsub#notify_config:0) (pubsub#notify_delete:0) (pubsub#notify_retract:1) (pubsub#purge_offline:0) (pubsub#persist_items:0) (pubsub#max_items:10) (pubsub#subscribe:1) (pubsub#access_model:open) (pubsub#roster_groups_allowed:NOT SET) (pubsub#publish_model:publishers) (pubsub#notification_type:headline) (pubsub#max_payload_size:60000) (pubsub#send_last_published_item:on_sub_and_presence) (pubsub#deliver_notifications:1) (pubsub#presence_based_delivery:0) (pubsub#itemreply:none)]
Then when I try to publish an event with next iq:
<iq to='pubsub.fm.ch' id='Z3Hsq-23' type='set'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='testNode'/>
</pubsub>
</iq>
I get bad-request error from the server with pubsub-specific condition error of item-required:
<iq xml:lang='en' to='***@fm.ch/***' from='pubsub.fm.ch' type='error' id='Z3Hsq-23'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='testNode'/>
</pubsub>
<error code='400' type='modify'>
<item-required xmlns='http://jabber.org/protocol/pubsub#errors'/>
<bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
</error>
</iq>
which is strange because by specification definition:
7.1.3.6 Request Does Not Match Configuration
...
- If the event type is persistent (either event notification or payload) and the publisher does not include an item, the service MUST bounce the publication request with a <bad-request/> error and a pubsub-specific error condition of <item-required/>.
item-required error should be sent back to the publisher in case that event type is persistent, which is not the case here as seen from node configuration.
I then tried to publish an event with empty item like:
<iq to='pubsub.fm.ch' id='gG7r4-23' type='set'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='testNode'>
<item/>
</publish>
</pubsub>
</iq>
and then I get wrong answer from the server again:
<iq xml:lang='en' to='***@fm.ch/***' from='pubsub.fm.ch' type='error' id='gG7r4-23'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='testNode'>
<item/>
</publish>
</pubsub>
<error code='400' type='modify'>
<payload-required xmlns='http://jabber.org/protocol/pubsub#errors'/>
<bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
</error>
</iq>
Again, by specification:
7.1.3.6 Request Does Not Match Configuration
...
- If the event type is payload (either persistent or transient) and the publisher does not include a payload, the service SHOULD bounce the publication request with a <bad-request/> error and a pubsub-specific error condition of <payload-required/>.
it means that my event is now considered as payload event, which is again wrong by node configuration set.
At the end, if I then publish full payload event like:
<iq to='pubsub.fm.ch' id='RCmTX-23' type='set'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='testNode'>
<item id='testItem'>
<payload>test</payload>
</item>
</publish>
</pubsub>
</iq>
then I get answer from the server:
<iq xml:lang='en' to='***@fm.ch/***' from='pubsub.fm.ch' type='error' id='RCmTX-23'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='testNode'>
<item id='testItem'>
<payload>test</payload>
</item>
</publish>
</pubsub>
<error code='400' type='modify'>
<item-forbidden xmlns='http://jabber.org/protocol/pubsub#errors'/>
<bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
</error>
</iq>
which is finally correct answer by specification:
7.1.3.6 Request Does Not Match Configuration
...
- If the event type is notification + transient and the publisher provides an item, the service MUST bounce the publication request with a <bad-request/> error and a pubsub-specific error condition of <item-forbidden/>.
Can anyone tell me if I have set something wrong, am I doing something wrong or there is some problem with my server?
You can try to publish that
You can try to publish that same problem as an issue in ejabberd github, maybe more pubsub experts read it there.
Thanks for the
Thanks for the tip!