Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Page:  1  2  next
Avatar
bartbert #1
Member since Sep 2005 · 22 posts
Group memberships: Members
Show profile · Link to this post
Subject: Components
How do you specify what subdomain that a particular component handles? I wrote a test application in C# using the XmppComponentConnection class. I can get it to open a connection. I have hooked all the events and the "OnReadXml", "OnWriteXml" and "StreamParser.OnStreamElement" are firing during the initial handshake. But once that has finished it doesn't seem to be receiveing any other messages.

I'm using JiveMessenger as the the server, and I can see that it has options to allow any component to connect, or only certain subdomains. It also has a screen to look at the details for connected components, and it has columns for Domain, Name, Category, and Type. My component shows a domain name of "localhost", but the other fields are empty.

Here's the output I get on the initial handshake:

<stream:stream to='localhost' xmlns='jabber:component:accept' xmlns:stream='http://etherx.jabber.org/streams'>
<stream:stream xmlns:stream="http://etherx.jabber.org/streams" from="localhost" id="9383d197" >
<handshake xmlns="jabber:component:accept">d4aeed3f06d2ca74c212aea41bc4e248f3412045</handshake>
<handshake xmlns="jabber:component:accept" />
<handshake xmlns="jabber:component:accept" />
<iq xmlns="jabber:component:accept" type="get" id="843-0" from="component.127.0.0.1" to="localhost.127.0.0.1"><query xmlns="http://jabber.org/protocol/disco#info" /></iq>
<iq xmlns="jabber:component:accept" type="get" id="843-0" from="component.127.0.0.1" to="localhost.127.0.0.1"><query xmlns="http://jabber.org/protocol/disco#info" /></iq>
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
hi brabert,

the last 2 IQ's look a bit weird to me. Could you give me more info about them? Are you sending the disco request to the server?

Alex
Avatar
bartbert #3
Member since Sep 2005 · 22 posts
Group memberships: Members
Show profile · Link to this post
No, I'm actually not sending anything to the server. Everything you see is just the result of opening a connection. Here's the output preceded by the event where it occurred:

OnWriteXml
<stream:stream to='localhost' xmlns='jabber:component:accept' xmlns:stream='http://etherx.jabber.org/streams'>
OnReadXml
<stream:stream xmlns:stream="http://etherx.jabber.org/streams" from="localhost" id="1c768987" >
OnWriteXml
<handshake xmlns="jabber:component:accept">0554799baa135a06ee97172784e7effaef5edeeb</handshake>
OnReadXml
<handshake xmlns="jabber:component:accept" />
OnLogin
OnStreamElement
<handshake xmlns="jabber:component:accept" />
OnReadXml
<iq xmlns="jabber:component:accept" type="get" id="802-0" from="component.127.0.0.1" to="localhost.127.0.0.1"><query xmlns="http://jabber.org/protocol/disco#info" /></iq>
OnStreamElement
<iq xmlns="jabber:component:accept" type="get" id="802-0" from="component.127.0.0.1" to="localhost.127.0.0.1"><query xmlns="http://jabber.org/protocol/disco#info" /></iq>
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
ok, this looks better now. The server send a disco-info query to your component. So you have to answer the disco request. the to attrib looks wrong to me with "localhost.127.0.0.1". or did you configure your component in the server to this domain?

Alex
Avatar
bartbert #5
Member since Sep 2005 · 22 posts
Group memberships: Members
Show profile · Link to this post
I didn't specifically configure my component in JiveMessenger. From what I saw on the JiveMessenger component configuration screen, there was a section at the top where you enable or disable components. If you enable components, then you specify a port number and a password. I enabled components, set a password, and used the default port, which was 10015.

The next section seems to allow you to specify which components should be allowed. The first option is "Anyone", which is what I chose for testing purposes. The second option is "White list", which then allows you to specify a subdomain and a password. I wasn't really sure how to associate my component with a specific subdomain.

The last section is basically a "Black list" in which you can specify components that are not allowed to connect. I left this section alone.
Avatar
Alex #6
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
try to add your component in the 2nd section "Allowed to connect", and choose a subdomain and secret for this component.
I will also make a test on my JiveMessenger.

Alex
Avatar
bartbert #7
Member since Sep 2005 · 22 posts
Group memberships: Members
Show profile · Link to this post
I tried that last night, and then I couldn't get my component to connect. I don't recall the exact message that came back, but it basically said that the connection attempt had been refused.

I may not have put in a valid subdomain. I think I put in "conference" because I wanted to hook into the group chat messages. I also wasn't sure if there was something that I was supposed to do in my component to associate it with the "conference" subdomain. I didn't see any properties or methods that looked like they would bind the component to a particular subdomain.

I will try it again this evening and post the messages that I'm getting back.
Avatar
Alex #8
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
im currently writing a sample to connect a component to my JM. The component stuff seams to be different here, than with the other servers i tried yet. In jabberd every component has its own port in the config file. In JM they all listen on the same port. This seems to be a problem with the current component class in agsXMPP. Could you try to modify the SendOpenStream function and add here a from attrib with the domain of your component. I assume that the only way JM can know which component is connecting when they all use the same port.

Alex
Avatar
bartbert #9
Member since Sep 2005 · 22 posts
Group memberships: Members
Show profile · Link to this post
Ok. I'll try that when I get home this evening and let you know how it goes.
Avatar
Alex #10
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
hi bartbert,

i had sucess to login to my JM server when i added the from attrib.
But i can only connect when to is localhost. When i set here the real domain i have no luck. I opened a posting in the Jive Forums with this problem.
I will upload the updated code later to SVN

Alex
Avatar
Alex #11
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
hi barbert,

i made changes in the XmppComponentConnection class. The latest working code is in the SVN repository. When you are not familar with SVN just send me a message and i will email you the code. I added a property ComponentJid. Make sure you assign this property with the Jid of your component before connectiong to the server.

Alex
Avatar
bartbert #12
Member since Sep 2005 · 22 posts
Group memberships: Members
Show profile · Link to this post
Great! I use Subversion at work, so I've already pulled down the code and will take a look at it this evening when I get home. Thanks!
Avatar
bartbert #13
Member since Sep 2005 · 22 posts
Group memberships: Members
Show profile · Link to this post
I pulled down the updated code, and tried it out in my test application. I am now getting the message events firing, which is terrific. Thank you for looking into that.

I have another question about closing down the connection. When I close the connection by calling the Close() method, it seems like something is not being properly cleared, because when I try to reconnect I get errors.

Here is the sequence of messages:

OnWriteXml
<stream:stream to='conference' xmlns='jabber:component:accept' xmlns:stream='http://etherx.jabber.org/streams'>
OnReadXml
<stream:stream xmlns:stream="http://etherx.jabber.org/streams" from="conference" id="bd83a6c5" >
OnWriteXml
<handshake xmlns="jabber:component:accept">2cf3bb2a80af64d4988512c6196494d51dd300a6</handshake>
OnReadXml
<handshake xmlns="jabber:component:accept" />
OnLogin
OnStreamElement
<handshake xmlns="jabber:component:accept" />
OnReadXml
<iq xmlns="jabber:component:accept" from="component.127.0.0.1" id="909-0" to="conference.127.0.0.1" type="get"><query xmlns="http://jabber.org/protocol/disco#info" /></iq>
OnStreamElement
<iq xmlns="jabber:component:accept" from="component.127.0.0.1" id="909-0" to="conference.127.0.0.1" type="get"><query xmlns="http://jabber.org/protocol/disco#info" /></iq>
The connection is open now, and then I call the Close() method
OnWriteXml
</stream:stream>
OnClose
Now I try to open the connection again
OnWriteXml
<stream:stream to='conference' xmlns='jabber:component:accept' xmlns:stream='http://etherx.jabber.org/streams'>
OnReadXml
<stream:stream xmlns:stream="http://etherx.jabber.org/streams" from="conference" >
OnWriteXml
<handshake xmlns="jabber:component:accept">e2f142ff6ea2d4ad8c63b3a0aa0e08d34ce33c82</handshake>
OnReadXml
<stream:error xmlns:stream="http://etherx.jabber.org/streams"><conflict xmlns="urn:ietf:params:xml:ns:xmpp-streams" /></stream:error>
OnStreamElement
<stream:error xmlns:stream="http://etherx.jabber.org/streams"><conflict xmlns="urn:ietf:params:xml:ns:xmpp-streams" /></stream:error>
OnReadXml
</stream>
OnClose


At this point, I have to restart JiveMessenger in order to be able to successfully open the connection again.
Avatar
Alex #14
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
i will look at this later in the afternoon.
What i have seen so far in your XML is that the open stream has a wrong TO attribute. When your server runs at localhost then it should be conference.localhost. I think its better to use domain names than IP adresses. But conference.127.0.0.1 should be also fine when the server run on the IP 127.0.0.1.

Alex
Avatar
Alex #15
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
OK, i tried it with my JM server and had no problems to close the connection and reconnect.

Here is the code of my test class. I also made one small change in agsXMPP and uploaded it to svn. But this change was only cosmetic and shouldnt affect the behaviour of XmppComponentConnection.

using System;

using agsXMPP;

namespace Component
{
    /// <summary>
    /// Summary description for Class1.
    /// </summary>
    class Class1
    {
        private static XmppComponentConnection comp = null;

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            comp = new XmppComponentConnection(&quot;localhost&quot;, 5555, &quot;mysecret&quot;);
            comp.ComponentJid = new Jid(&quot;test.gnauck.dyndns.org&quot;);
            comp.OnLogin    += new ObjectHandler(comp_OnLogin);
            comp.OnClose    += new ObjectHandler(comp_OnClose);

            comp.OnRoute    += new agsXMPP.XmppComponentConnection.RouteHandler(comp_OnRoute);           
            comp.OnReadXml    += new XmlHandler(comp_OnReadXml);
            comp.OnWriteXml    += new XmlHandler(comp_OnWriteXml);           

            comp.Open();

            Console.ReadLine();
            comp.Close();
           
            Console.ReadLine();
           
            Console.WriteLine(&quot;And open the Connection again&quot;);
            comp.Open();
            Console.ReadLine();

            comp.Close();
           
            Console.ReadLine();
           
        }

        private static void comp_OnClose(object sender)
        {
            Console.WriteLine(&quot;OnClose\r\n&quot;);
        }

        private static void comp_OnLogin(object sender)
        {
            Console.WriteLine(&quot;OnLogin\r\n&quot;);
        }

        private static void comp_OnRoute(object sender, agsXMPP.protocol.component.accept.Route r)
        {

        }

        private static void comp_OnReadXml(object sender, string xml)
        {
            Console.WriteLine(&quot;OnReadXml: &quot; + xml + &quot;\r\n&quot;);
        }

        private static void comp_OnWriteXml(object sender, string xml)
        {
            Console.WriteLine(&quot;OnWriteXml: &quot; + xml + &quot;\r\n&quot;);
        }
    }
}
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Page:  1  2  next
Forum: agsXMPP RSS