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: Component sending message problem
I have written a simple server component, and a simple client application. I was trying to test to see whether I could send messages back and forth between the client and the server component. I am finding that I can send messages from the client to the server component, but the message from the server component to the client is not being received.

Here is the message from the client to the server component:


<message xmlns="jabber:client" to="games.dilbert"><body /><weather xmlns="bartbert:weather"><humidity>90</humidity><temperature>57</temperature></weather></message>


And here is the message being received by the server component:


<message xmlns="jabber:component:accept" from="brian@dilbert/b579460d" to="games.dilbert"><body /><weather xmlns="bartbert:weather"><humidity>90</humidity><temperature>57</temperature></weather></message>


Here is the message from the server component to the client that never gets received:


<message xmlns="jabber:client" to="brian@dilbert"><body>Test message</body><weather xmlns="bartbert:weather"><humidity>90</humidity><temperature>57</temperature></weather></message>


The format of the message looks correct. Is there something special you have to do in order to receive a message from a server component?
Avatar
Alex #2
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello barbert,

look at the namespaces from the message you receive and the message you send. You are using the jabber:client namespace which is only used for client-server and server-client connections. Try to send your message with the jabber:component:accept namespace. I could add some more constructors to the message class to specify the different namespaces for client, server and component communication if its helpful for you.
Which server are you using? Normally the server should return an error message and not drop your packet silently.
Let me know if it works with the correct namespace.

Alex
Avatar
bartbert #3
Member since Sep 2005 · 22 posts
Group memberships: Members
Show profile · Link to this post
I tried changing the namespace, but I don't think I'm doing it correctly. Immediately after sending the message, the server is disconnecting the server component. Here is the XML being sent:


<stream:stream to='games.devws855' xmlns='jabber:component:accept' xmlns:stream='http://etherx.jabber.org/streams'>
<handshake xmlns="jabber:component:accept">01bd59f31ddd836431dff2feab979f7d17a34819</handshake>
<route xmlns="jabber:component:accept" to="brian@devws855"><weather xmlns="bartbert:weather"><humidity>90</humidity><temperature>57</temperature></weather></route>


And here is the response from the server:


<stream:stream xmlns:stream="http://etherx.jabber.org/streams" from="games.devws855" id="cbbee8cd" >
<handshake xmlns="jabber:component:accept" />
<iq xmlns="jabber:component:accept" from="component.devws855" to="games.devws855" type="get" id="947-4"><query xmlns="http://jabber.org/protocol/disco#info" /></iq>
</stream:stream>


I am using Wildfire for the server, and here is what it says in the logs:


2006.06.08 07:37:38 Unexpected packet tag (not message,iq,presence)<route to="brian@devws855"><weather xmlns="bartbert:weather"><humidity>90</humidity><temperature>57</temperature></weather></route>


And here is the code I'm using to send the message:

            WeatherMessage weather = new WeatherMessage(90, 57);

            Jid to = new Jid(String.Format("brian@{0}", this.txtServerName.Text.ToLower()));
            agsXMPP.protocol.component.accept.Route msg = new agsXMPP.protocol.component.accept.Route();
            msg.Type = agsXMPP.protocol.component.accept.RouteType.NONE;
            msg.To = to;
            // Add our weather Element
            msg.AddChild(weather);
            // Send the message
            this.xmppConn.Send(msg);


So, I can see that the packet that I'm sending is not a "message", "iq" or "presence" tag, but I'm not sure how to send the correct message using the available objects. Thanks.
Avatar
Alex #4
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello bartbert,

send your message liek before and use the same object to create the message and change the namespace of the message packet.

  1. agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message();
  2. msg.Namespace = Uri.ACCEPT;
  3. // add your custom stuff here

Alex
Avatar
bartbert #5
Member since Sep 2005 · 22 posts
Group memberships: Members
Show profile · Link to this post
The message being sent from the server component is now the following:

<message xmlns="jabber:component:accept" to="brian@devws855"><weather xmlns="bartbert:weather"><humidity>90</humidity><temperature>57</temperature></weather></message>


Unfortunately, the client doesn't seem to be receiving the message. The Wildfire server logs don't show any warning or error messages to indicate why the message would not have been delivered. Any ideas on what I should check?
Avatar
Alex #6
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
can you try to send a "normal" message (message without your custom weather stuff). And can you also try to add a from attribute. Some servers drop message without from and to attrib on s2s and component connections because they are not optional here.

Alex
Avatar
Alex #7
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello bartbert,

i misunderstood you. After reading all your post again i think i got it now  :-D
You have to embed all stanzas (message, iq and presence) you send from your component in the route element. Please forget all the namespace stuff. So a message which you route/send from your component shoudl look like this:

  1. <route from='...' to='...'>
  2.  <message xmlns='jabber:client' to='...' from='...' type='normal'>
  3.     <body>Hello World</body>
  4.  </message>
  5. </route>

Alex
Avatar
bartbert #8
Member since Sep 2005 · 22 posts
Group memberships: Members
Show profile · Link to this post
No luck with the "route" element. I get the following warning in the server log and then it disconnects the server component:

Unexpected packet tag (not message,iq,presence)
<route from="games.dilbert" to="brian@dilbert">
    <message to="brian@dilbert"><body>Test message</body>
        <weather xmlns="bartbert:weather">
            <humidity>90</humidity>
            <temperature>57</temperature>
        </weather>
    </message>
</route>


From what I have read, it sounds like "route" packets are sent from component to component, so maybe that's not the right way to go anyway. I also tried sending a "message" packet with both a "from" and a "to", but it didn't get received.

I may try having the client send an "iq" packet to the component and see if the component can successfully send a response, but it sure seems like it should be possible for a component to just send a message to one or more clients.
Avatar
Alex #9
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
it doesnt matter if you send a message, presence or iq packet.
I will try it on a local wildfire server and post my results with sample code.

Alex
Avatar
Alex #10
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello bartbert,

i just wrote a small sample and i have no problem to send messages from a component which i connect to my wildfire server.
The domain of my server is alex, the domain of my component is comp.alex.

Here is the code to login my component and setup the event handlers:

private XmppComponentConnection comp = null;

  1. comp = new XmppComponentConnection("localhost", 10015, "secret");
  2. comp.ComponentJid = new Jid("comp.alex");
  3. comp.OnLogin    += new ObjectHandler(comp_OnLogin);
  4. comp.OnClose    += new ObjectHandler(comp_OnClose);
  5.  
  6. comp.OnRoute    += new agsXMPP.XmppComponentConnection.RouteHandler(comp_OnRoute);  comp.OnReadXml    += new XmlHandler(comp_OnReadXml);
  7. comp.OnWriteXml += new XmlHandler(comp_OnWriteXml);     
  8.  
  9. comp.Open();

in the login handler i send a message to the admin user of this server with the jid admin@alex

  1. private static void comp_OnLogin(object sender)
  2. {
  3.     Console.WriteLine("OnLogin\r\n");
  4.     agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message();
  5.            
  6.     msg.Namespace = agsXMPP.Uri.ACCEPT;
  7.     msg.Body = "test";
  8.     msg.From = new Jid("comp.alex");
  9.     msg.To = new Jid("admin@alex");
  10.    
  11.     comp.Send(msg);
  12. }

i also tried it with the default namespace jabber:client and it worked. So wildfire is very fault tolerant and does not care about the namespace. But this is not correct

Alex
Avatar
bartbert #11
Member since Sep 2005 · 22 posts
Group memberships: Members
Show profile · Link to this post
That's pretty much what my component code looks like as well. What does your client code look like, and could you also post the XML that the component sends as well as what the client receives? Thanks.
Avatar
Alex #12
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
as the client i took exodus and sent my XML with the debug console.

This is my XMLdebug of the component:

OnWriteXml: <stream:stream to='comp.alex' xmlns='jabber:component:accept' xmlns:
stream='http://etherx.jabber.org/streams'>
OnReadXml: <stream:stream xmlns:stream="http://etherx.jabber.org/streams" from="
comp.alex" id="d437cf28" >
OnWriteXml: <handshake xmlns="jabber:component:accept">9056c74f099e7099db87b6fe5
00b25af89be8b43</handshake>
OnReadXml: <handshake xmlns="jabber:component:accept" />
OnLogin
OnWriteXml: <message xmlns="jabber:component:accept" from="comp.alex" to="admin@
alex"><body>test</body></message>
OnReadXml: <iq xmlns="jabber:component:accept" from="component.alex" to="comp.al
ex" type="get" id="495-1"><query xmlns="http://jabber.org/protocol/disco#info" /
></iq>
OnWriteXml: </stream:stream>
OnReadXml: </stream:stream>
Avatar
bartbert #13
Member since Sep 2005 · 22 posts
Group memberships: Members
Show profile · Link to this post
Hmmm. As you noted, if I use Exodus as my client and turn the debug window on, I can see the message sent from my server component. But if I use the simple client application I wrote, it doesn't seem to receiving the message. Or if it is receiving the message, it isn't displaying it for some reason. I am hooking the OnReadXml and OnWriteXml events, which I assume should capture any incoming or outgoing messages.

Any thoughts on what I might be doing wrong with my client that would prevent it from displaying the message coming from the server component?
Avatar
Alex #14
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
If you hook the OnReadXML and OnWriteXML this should display all incoming stanzas. You can also try to hook the Incoming and Outgoing raw socket data. And if there is still no incoming data you can try to set breakpoints in clientsocket.cs where the data is received before it gets processed and parsed from agsXMPP.
If you send the message to the corrent resource i have no idea whats going wrong here.

Alex
Avatar
bartbert #15
Member since Sep 2005 · 22 posts
Group memberships: Members
Show profile · Link to this post
Well, here's what I have learned.

1. If I send a message from the Wildfire admin console, my test client application properly receives the following message:

<message xmlns="jabber:client" from="dilbert" to="brian@dilbert/DiF"><body>hello world</body></message>


2. If I send a message from the Exodus client, my test client application never receives anything. I put a break point in the ClientSocket.EndReceive method, and it never hit the break point. Here's the XMl that the Exodus client sent:

<message id="" to="brian@dilbert"><subject>Test Message</subject><body>Hello World</body></message>


3. If I send a message from my test client to the Exodus client, Exodus properly receives the message as shown here:

<message to="admin@dilbert" from="brian@dilbert/DiF"><body>hello world</body><weather xmlns="bartbert:weather"><humidity>90</humidity><temperature>57</temperature></weather></message>


4. If I have the Exodus client reply to the message sent from my test client application, it still is never received:

<message id="" to="brian@dilbert/DiF"><body>hello to you</body></message>


So basically, my test client application is never receiving the messages being sent to it, as if the Wildfire server is blocking the messages.
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