The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Jonwright (5) [Avatar] Offline
#1
Hello,

Firstly, very nice book. Does a great job of explaining the concepts of IM.

Okay my problem. I have built the server from Chapters 2 & 3 and everything compiles correctly smilie. I then start the server up from a cmd window and get the following

Jabber Server-- 192.168.1.102:5222

the ip is my local ip on my network. I have tried using a domain name and also the local host address 127.0.0.1

I then start up telnet and set echo to on. Then I try to open up a connection to the server and it just seems to sit there. Telnet screen says

Connecting To 192.168.1.102...

This also happens whichever IP or domain name I try and use.

So my question is this:

Does anybody have any idea why the above is happening? Has anybody had the same problems and been able to solve them.

Any comments would be much appreciated.

Thanks in advance
iain (56) [Avatar] Offline
#2
Re: Telnet Problems When Connecting to Server
Hi,

I'm uncertain whether you're actually connecting with telnet or not. One thing you need to make sure of is that your telnet is attaching to port 5222 (or whatever port you're running the server on) rather than the default telnet port. Some telnets use a -p option to indicate the port. The telnet program should then give you a "connected" response of some sort. If you've gotten that far, there's a walkthrough in the book of the 'conversation' that should occur between you (via telnet) and the server - see page 49.

If you are using the correct port setting then it's really hard to tell why you wouldn't be able to connect via telnet. One remote possibility is you have a firewall blocking the jabber port and preventing the connection.

-iain
Jonwright (5) [Avatar] Offline
#3
Re: Telnet Problems When Connecting to Server
Thanks for the quick response Iain.

I'm pretty sure I'm connecting with Telnet. I even downloaded and install sygate firewall so I could monitor applications on the network. The server started listening on port 5222 and when I connected via telnet the server Connected on port 5222.

Its a very strange one. I do run a router so that maybe blocking connection on the port.

I'll try forwarding the port on the router and see if that makes any difference.

Further to this I added some simple System output statements to try and find out if the server was receiving the request when I tried to connect via telnet. The server starts, I open telnet give it host name and 5222 as the port. The server then outputs in the cmd window that it has recieved a connection. However telnet just refuses to budge. It simply sits there saying:

Connecting To hostname...

I'm almost running out of ideas :'(


Message was edited by: Jonwright
iain (56) [Avatar] Offline
#4
Re: Telnet Problems When Connecting to Server
Hi,

Ah, so you are connecting and are waiting for the server to send something? In Jabber the client must start first. smilie So just type in the opening stream element as shown in bold on p49. The server will respond with it's own stream element when it receives yours. Note that in most telnet applications, you'll need to hit return/enter in order for the telnet to actually send the text you type (you can't just type the stream tag and wait, you have to type the stream tag and hit enter).

Oh, and for debugging network protocols outside of the software itself, there's no better tool than a good packet analyzer. Ethereal works well and is free. If you're on windows there's a very simple to use GUI enabled version from Network Chemistry called Packetyzer that you can try.

-iain
Jonwright (5) [Avatar] Offline
#5
Re: Telnet Problems When Connecting to Server
ahh, I think I caused some confusion. What seems to be happening is I'm actually not able to write anything in the telnet window.

This seems to be because telnet is not connecting properly to the server.

So, I start the server from a cmd prompt and it begins. It displays its banner. I then open telnet and type

hostname 5222

telnet then says:

Connecting To hostname...
But it doesnt appear to connect so I am never able to type out the first <stream:> packet.

I have made sure echo is on so I dont think thats the problem.

I suppose my question is "Should I see a command prompt flash once the server connects correctly?"
iain (56) [Avatar] Offline
#6
Re: Telnet Problems When Connecting to Server
Hi,

It depends on the telnet application you're using. On *nix systems (including Mac on the Terminal) you don't see anything other than the "Connected to server.com" message. On Windows if you're using the command line application it doesn't flash a cursor (there is no curser). You'll have to type, and hit enter to see anything (even with echo on I believe). The best approach is to type everything into a text editor and copy and paste it into the telnet window (hitting enter after pasting something in - you can hit enter several times to make sure since XML doesn't care about extra whitespace between elements).

Could you cut and paste all the text in the command window you have for starting up the server, as well as for your telnet session?

I'm really suspecting this is a network issue above and beyond the Jabber software. One easy way to test is to grab the Messenger server from http://www.jivesoftware.org and follow the installer, and use some normal Jabber/XMPP client to conncect to the server to make sure everything is OK. Then use telnet to that server to make sure your telnet usage is working. Once you have all that work, switch back to the compiled server (turn off the Jive Messenger server or the 5222 port will be taken up and your server won't start on it).

Another is to find an existing Jabber server online and running and telnet to it to make sure your telnet experience is correct. One obvious choice is the jabber server running at jabber.org

-iain
Jonwright (5) [Avatar] Offline
#7
Re: Telnet Problems When Connecting to Server
Hello Iain,

thanks again for getting back to me. This is the command I use to start the server up from a cmd prompt.
The first path is where the Xerces files are kept which enable me to use StreamingCharFactory. Next up tells
the compiler to compile the current directory I'm in and then finally where my xerces files are kept.

I think its correct. Well it compiles anyhow, I have wondered if the problem could be related to the the
Xerces Parser buffering the input and as you mentioned in the book getting stuck. I thought that by putting
the Xerces path first though would overcome this problem.

java C:j2sk1.4.2_01xerces-2-0_0libxerces.jar;.;C:j2sdk1.4.2_01xerces-2_0_0xercesImpl.jar Server

On typing this in the server starts up and displays

Jabber Server 192.168.1.102 - 5222

The IP address is my address on my local network. Is this the address I should be using?

I have tried lots of different things. I used by hostname, I have disconnected myself from the network and just tried
using 127.0.0.1 but they all produce the same results!

I then start telnet and set localecho to on. I then type open localhost 5222. Telnet then displays
Connecting To localhost...

Nothing happens after this. It will just sit there forever by the looks of it. I tried a test to see if
telnet was working on my machine by connecting to Jabber.org

This produced the following results.

Connecting to Jabber.org...

After about 20 seconds I got a blank screen screen and was able to type packets in. The Jabber.org server
responded to me so it looked like that that worked fine.

Whats strange is if I try and telnet into the Server before I start the server it will tell me it cant connect.
This of course is correct as there is nothing to connect to. Its when the Server is running and I try and connect, it just appears to be blocking somewhere
but I am not sure where this could be.
iain (56) [Avatar] Offline
#8
Re: Telnet Problems When Connecting to Server
Hi

I think you may have figured it out. If you don't have the correct version of Xerces on the classpath, you won't get the patched parser behavior that lets it read Jabber packets correctly. I'm not sure why your commandline is working because I don't think it's the correct syntax. I belive you should haev to type:

java -classpath csmilieerces.jar;csmilieercesImpl.jar Server

without the -classpath switch the arguments should be "wrong" and the server shouldn't start. Could you try to add the -classpath switch?

-iain
Jonwright (5) [Avatar] Offline
#9
Re: Telnet Problems When Connecting to Server
Sorry Iain, my mistake. I have been using the -classpath option. You have to otherwise the java compiler throws a wobbly.

I just forgot to include it in my last post.

I do believe it must be something to do with the JabberInputHandler though.

I discoverd today that if I close down the server while I have the telnet session trying to connect telnet tells me that my connection to the host has been lost.

So it is definately connecting, it just doesnt allow me to send packets.
iain (56) [Avatar] Offline
#10
Re: Telnet Problems When Connecting to Server
If the telnet session does close down when you kill the server then it must be accepting the connection. Are you making sure to type in the opening stream XML into your telnet session and hitting enter? If the correct version of Xerces is being used, and you have the patched reader class from the book source, it should be reading the streaming XML.

Oh, try this, type in the opening XML in the telnet session hit enter, if nothing happens, try to hit ^D which is the end of file character. If nothing happens, try to connect with a new telnet session, send the XML opening stream element, then hit enter, then close the telnet session - usually ^].

See if the server responds to either case - if it does, it's connecting and working correctly but not reading the stream correctly (it's trying to buffer the input and parse it later rather than parse it as it receives it - and that's what the patched Xerces reader class in the book source is supposed to work around).

Let me know what you get. If you're ambitious the other thing to do is to create an empty implementation of an InputStream that basically passes the inputstream read() calls while printing them to stdout. You can hook that up between the real inputstream from the socket, and the xerces parser so that you can see what the parser is actually doing. I suspect it's blocking on an array read of 1k or something which indicates the streaming workaround isn't working.

Let me know what you find.

-iain