Sending a message to a specific Resource

Hi,

I’m using Jabber-net and Openfire for an application I’m writing which uses messaging to perform various function on a users system.

My application can have a number of contexts when it is running for example, test/staging/live.

As such when a user starts the application they will create a Jabber session with the relevent context as Resource, e.g. edward@server/live

The problem is that when I send a message to edward@server/live it will also get sent to edward@server/test and edward@server/staging.

In my reading I thought that if you specified the Resource in the JID of the recipient the message would only get sent to that recipient, is this correct?

If it is correct does anybody have any possible ideas what else I might be doing wrong?

I’m developing a Windows Forms application in .Net using Jabber-net.

I have my Openfire Server running as a windows service on a Windows Server 2003 box.

If anybody has ideas, any help would be appreciated.

Thanks

Ed

Sorry for this message, it was automatically generated by my mail bot.

OK. Tried a number of different things to narrow the possibilities and no messages are getting routed to a specifically defined Resoure. Anybody?

Ed

It works fine for me.

I have tested this with Exodus and Spark clients logged in with user1 account (with Exodus and Spark resources). Then i have logged in with user2 in JBother client. Well this was the quickest way to test as i always has Spark/Exodus installed and JBother doesnt have to be installed and i dont want to mess creating several Windows users Also this should be a more realistic scenario. Then in JBother i have send a simple message to user1@server. Exodus user (and only he) got that message. Then i send a message to user1@server/Spark. Only the Spark client got that message.

I think there was some system property which was forcing all resources to receive a copy of a message, but i cant remember its name and cant find it in the list of Openfire properties. Not a big chance, but maybe you should check your system properties.

Thanks for your response.

I have done further investigation this morning, and it would appear that it is partly the lack of my understanding and partly a confusing way in which messages are getting delivered when a resource is supplied.

If I have two user sessions active.

  1. ed@server/live

  2. ed@server/test

If both sessions are connected and I send a message to user 1 only user one gets the message.

However if user 1 session is not active and I send a message to user 1 it will get delivered to user 2 (a session on a completly different resource).

This seems odd to me, why does Openfire just not deliver the message instead of sending it to the session with a different resoure?

The other thing that was confusing matters is, the broadcast plugin I’m using doesn’t care if a resource is specified.

Is there any way I can specify a broadcast to only be delviered to a specific resource?

Thanks

Ed

I’m not sure, but probably such behavior is by xmpp standards. So, you will have to code some custom routing mechanics (plugin maybe).

This seems odd to me, why does Openfire just not deliver the message instead of sending it to the session with a different resoure?
Because this is the way how XMPP works and is defined in the RFC 3921.

Is there any way I can specify a broadcast to only be delviered to a specific resource?
I’m confused. Broadcasting means send a message to all.

What do you want to do?

Send a message to clients which understands your message, therefore you should have a look in Service Discovery. Or do you want to handle a group of users therefore you should look at the group package.

Cheers for that, still seems odd behaviour to me even it is in the standard. By sepcifiying a Resource I want it to go only to a session defined by that Resource. Anyway thanks for clarifying, and now I know the behaviour I can deal with it.

Re: broadcasting, I guess I would like to broadcast to a group of users defiend by their session resource. I do now appreciate that’s not quite the intended use of it and again I can deal with the problem another way.

Cheers.

Cheers for that, still seems odd behaviour to me even it is in the standard.

That’s probably because resource is not intended for message routing and defining whether to send the message or not. It was implemented just for the conflicts solving, when one username is logged in more than one place. If there is only one user session, then server is not looking at resources and priorities at all.

Fair enough, I hope you can see how a beginner to the standard could become confused.

So the answer is, “resource is not intended for message routing and defining whether to send the message or not”

Thanks.

Cheers for that, still seems odd behaviour to me even it is in the standard.
I want to encourage you to read the standard. I think XMPP is a great protocol and I learned a lot from it. What you mean is not broadcasting but rather multicasting and yes ressouces are not intended for multicasting. But there exists a extension for Extended Stanza Addressing and if you send IQ packets instead of Messages your described behavior is implementet, thats because IQ stanzas are intendend for handling in an application and not presented directly to the user. But by the way many extensions are based on the RFC and implement several great applications such as Publish-Subscribe for example (which may also be useful for your application), not only Instant Messaging.

I agree, I should fully read the standard. I will have a look at the information you have provided.

Thank you for your help.

So the answer is, “resource is not intended for message routing and defining whether to send the message or not”

Thats not really correct, they are intended and used for message routing, but not in the way which you was thinking. In XMPP each user should have a JID and a message is a type of a XML stanza which transports information to a user. And therefore the behavior of the standard is correct. The user has the power to manipulate the routing of messages by priorities, etc. and the user has also the power to change their ressource. So if you want to describe a message multicasting by their ressource you must tell each user what ressource is good for and each client have to respect this “special resource”. And thats really too complicated for users which only wants to chat.

Hi,

I am another XMPP beginner who is getting confused by the message routing too.

If I sent a message to a full JID I expect that the resource which is specified and online receives the message regardless to any priority. My expectation results from the following rules in the standard:

http://xmpp.org/rfcs/rfc6121.html#rules-localpart-fulljid

Is there any extension which overrules these?

Hi, Rene,

I think you are right in your assumption, though i haven’t just tested this, but i think it should work like this. If you specify a resource, then the message is only delivered to that resource no matter what priorities are set. I think it should not deliver a message to anybody if that resource is unavailable. Maybe i will test this later today to be sure.

I was a bit wrong. Openfire will route the message to any other resource available if it can’t find the resource specified in the message. But if the resource specified in the message is available, then only that resource gets the message.

Hi again,

thx for the fast reply.

During my tests with 3.7.0 I saw that Openfire routes the message to the resource with the highest priority. Only if two resources have the same priority it routes the message to the resource which was provided by the sender. The receiver was online on all resources.

I think Openfire should ignore any priorites if the sender specifies a resource which is online.

What do you think?

In my test i didn’t observe such behavior. I had such users logged in:

test@server/Spark

test@server/Exodus

Resource Spark had priority 10 and Exodus just 1. I was sending a message to test@server/Exodus and only that resource was getting the message. Spark resource did get the message when Exodus resource went offline.

I’ve just retested and it works as you say and as I had expected. Must have been a bug in my test.

Thx for your help.