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.

import-bot (20211) [Avatar] Offline
#1
Re: groupchat problems
[Originally posted by iainshigeoka]

> I get an error on the server, this is the sequence I see on the server:
>
> 11:49:42:665 ChatMan: is chat packet: java-users.group@shigeoka.com/Marquinho
> 11:49:42:675 11:49:42:675 [XC]
> 11:49:42:675 PresenceHandler: groupchat presence
> 11:49:42:675 ChatMan: is chat packet: java-users.group@shigeoka.com/Marquinho
> [XE] finished with stream:stream
> 11:49:42:685 [PQ] </stream:stream/>
> 11:49:42:685 ChatMan: handling presence for Marquinho in
java-users.group@shigeo
> ka.com
> 11:49:42:695 ChatMan: user null joining
java-users.group@shigeoka.com/Marquinho
> 11:49:42:705 QueueThread: java.lang.NullPointerException
>
> Can you tell me what I might possibly doing wrong on my client? or there's any
> problem with the server?

In the middle, the server is getting a </stream:stream> packet from the client
which closes the stream for the server. Since the user has left, the server
breaks (NullPointerException). There is no error checking or nice cleanup of
abruptly vanishing clients in the server code. I'm guessing that for some
reason your client is reacting to new server behavior from chapter 7 and 8 by
leaving prematurely.

One thing that may help is to change the toString() method for the Packet
class to put the session.toString() in part of the packet toString() output.
This will be noisier but will help to tell which packets are coming from which
client (by session id). Hope that made sense.

Try making that modification (session info in Packet.toString) and running the
same thing again. Then post that back here if it doesn't lead you to answers.
It may also make your client debugging a bit easier (I think the problem is
actually coming from the client but obviously the server is broken in its
handling of the situation).

-iain

ps - If you're only interested in client development, now that you've got
authentication support working, you can switch over to testing against a
full-fledged Jabber server. The one at www.jabber.org is a nice one to test
against, or you can download the free 100 user server from jabber.com. If
you're interested in both client and server development in Java you can ignore
this ps. smilie
import-bot (20211) [Avatar] Offline
#2
Re: groupchat problems
[Originally posted by marcoe08]

As you pointed out, on the last sequence I sent you a </stream:stream/> packet
appears. That was from a different client. I have run my client again alone
(i.e. only one client connected to the server) and this is the entire sequence
that I saw:

15:41:46:423 [XS] URI: jabber:client lName: presence qName: presence
15:41:46:433 [XE] finished with presence
15:41:46:443 [PQ] <presence type='available' to='convivo-users.group@shigeoka.co<br /> m/marquinho'/>
15:41:46:463 ChatMan: is chat packet: convivo-users.group@shigeoka.com/marquinho

15:41:46:483 PresenceHandler: groupchat presence
15:41:46:483 ChatMan: is chat packet: convivo-users.group@shigeoka.com/marquinho

15:41:46:503 ChatMan: handling presence for marquinho in convivo-users.group@shi
geoka.com
15:41:46:523 ChatMan: user null joining convivo-users.group@shigeoka.com/marquin
ho
15:41:46:543 QueueThread: java.lang.NullPointerException
15:41:46:553 QueueThread: at java.util.Hashtable.put(Unknown Source)
15:41:46:573 QueueThread: at com.metamech.vorpal.GroupChatManager.joinGrou
p(GroupChatManager.java:103)
15:41:46:593 QueueThread: at com.metamech.vorpal.GroupChatManager.handleCh
atPresence(GroupChatManager.java:76)
15:41:46:623 QueueThread: at com.metamech.vorpal.PresenceHandler.notify(Pr
esenceHandler.java:33)
15:41:46:633 QueueThread: at com.metamech.jabber.xml.QueueThread.run(Queue
Thread.java:63)

Any other ideas?

Thanks,
Marco

ps. I didn't test my client with the jabber.com server because my client needs
a little bit more development... that's why I'm starting testing with your
server code
import-bot (20211) [Avatar] Offline
#3
Re: groupchat problems
[Originally posted by iainshigeoka]

> 15:41:46:503 ChatMan: handling presence for marquinho in
convivo-users.group@shi
> geoka.com
> 15:41:46:523 ChatMan: user null joining
convivo-users.group@shigeoka.com/marquin
> ho
> 15:41:46:543 QueueThread: java.lang.NullPointerException
> 15:41:46:553 QueueThread: at java.util.Hashtable.put(Unknown Source)

Looks like my lack of error handling coming back to haunt us. smilie when a user
leaves the server, the server removes the Session object from the sessions
hashtable, but doesn't remove it from the chat hashtables. In other words it
relies on a client exiting all chats before logging out. This is a major, bad
assumption especially when testing clients because clients will often crash or
otherwise leave abruptly.

In fact, I think when a client crashes, the User session doesn't even get
removed from the session hashtable and stranger errors will occur. (sending
messages to these phantom users will probably result in
NullPointerExceptions.)

All of this is a big build up to the simple work around. Restart the server
everytime you run a new test of your client. this starts you off with a clean
hashtable everytime (and is the reason I didn't bother to put any effort into
keeping the hashtables from getting corrupted).

Hope that gets you back on track.

> ps. I didn't test my client with the jabber.com server because my client needs
> a little bit more development... that's why I'm starting testing with your
> server code

I'm glad its a useful tool. The big open source jabber server is a bear to
setup and quite overkill for simple client development. I'm hoping one of the
readers of my book will take bits from my server and build on it to create a
truly useful Java Jabber server. The Jabber community could really use a
small, but "correct" Jabber server for development and smaller IM setups.

If anyone here is interested, you don't need my permission, just go do it! If
you start putting code together, I'll have Manning edit the book's webpages to
point to it so we can get a community going. (the same applies to Java Jabber
clients based on the book source too).

-iain
import-bot (20211) [Avatar] Offline
#4
[Originally posted by marcoe08]

Hi,
I have added the groupchat support to my jabber client. My client runs fine
with the server from chapter 5. However, when I try to run my client with
server from chapter 7 or 8, the groupchat support seems to be broken.
(of course I register and authenticate before sending presence)

When I send a <presence> packet like:

model.sendPresence(groupName + nickName,"available", null, null, null);

I get an error on the server, this is the sequence I see on the server:

11:49:42:665 ChatMan: is chat packet: java-users.group@shigeoka.com/Marquinho
11:49:42:675 11:49:42:675 [XC]
11:49:42:675 PresenceHandler: groupchat presence
11:49:42:675 ChatMan: is chat packet: java-users.group@shigeoka.com/Marquinho
[XE] finished with stream:stream
11:49:42:685 [PQ] </stream:stream/>
11:49:42:685 ChatMan: handling presence for Marquinho in java-users.group@shigeo
ka.com
11:49:42:695 ChatMan: user null joining java-users.group@shigeoka.com/Marquinho
11:49:42:705 QueueThread: java.lang.NullPointerException

Can you tell me what I might possibly doing wrong on my client? or there's any
problem with the server?

Thanks
Marco Escobedo
import-bot (20211) [Avatar] Offline
#5
Re: groupchat problems
[Originally posted by marcoe08]

> > 15:41:46:503 ChatMan: handling presence for marquinho in
> convivo-users.group@shi
> > geoka.com
> > 15:41:46:523 ChatMan: user null joining
> convivo-users.group@shigeoka.com/marquin
> > ho
> > 15:41:46:543 QueueThread: java.lang.NullPointerException
> > 15:41:46:553 QueueThread: at java.util.Hashtable.put(Unknown Source)
>
> Looks like my lack of error handling coming back to haunt us. smilie when a user
> leaves the server, the server removes the Session object from the sessions
> hashtable, but doesn't remove it from the chat hashtables. In other words it
> relies on a client exiting all chats before logging out. This is a major, bad
> assumption especially when testing clients because clients will often crash or
> otherwise leave abruptly.
>
> In fact, I think when a client crashes, the User session doesn't even get
> removed from the session hashtable and stranger errors will occur. (sending
> messages to these phantom users will probably result in
> NullPointerExceptions.)
>
> All of this is a big build up to the simple work around. Restart the server
> everytime you run a new test of your client. this starts you off with a clean
> hashtable everytime (and is the reason I didn't bother to put any effort into
> keeping the hashtables from getting corrupted).
>
> Hope that gets you back on track.

I always restart the server before running a new test. The error that I
mentioned to you occurs at the beginning (i.e. that means the first time I
send an available presence message tojoin a group)
other suggestions where to look at? or where the problem might be?

Thanks,
Marco
import-bot (20211) [Avatar] Offline
#6
Re: groupchat problems
[Originally posted by marcoe08]


I always restart the server before running a new test. The error that I
mentioned to you occurs at the beginning (i.e. that means the first time I
send an available presence message tojoin a group)
other suggestions where to look at? or where the problem might be?

Thanks,
Marco
import-bot (20211) [Avatar] Offline
#7
Re: groupchat problems
[Originally posted by iainshigeoka]

Hi Marco,

Sorry about the delay in replying. Mail forwarding problems made me misplace
email since the 15th and I'm just now catching up. (I'm alerted to new posts
to the forum via email).

> I always restart the server before running a new test. The error that I
> mentioned to you occurs at the beginning (i.e. that means the first time I
> send an available presence message tojoin a group)
> other suggestions where to look at? or where the problem might be?

Hmm. I'm a bit stumped. I was sure it was a restart problem. If you send me
your code I can give it a whirl and see if I can uncover anything.

-iain

ps - email it to "iain dot shigeoka at messaginglogic dot com"
import-bot (20211) [Avatar] Offline
#8
Re: groupchat problems
[Originally posted by micael]


you can download the free 100 user server from jabber.com. If
> you're interested in both client and server development in Java you can ignore
> this ps. smilie


I found a 10-user free download, but no 100 user server. Do you have the url?

-Micael
import-bot (20211) [Avatar] Offline
#9
Re: groupchat problems
[Originally posted by iainshigeoka]

>
> you can download the free 100 user server from jabber.com. If
> > you're interested in both client and server development in Java you can
ignore
> > this ps. smilie
>
> I found a 10-user free download, but no 100 user server. Do you have the url?

They must have changed the demo version user limit. Sorry. It used to be 100
users. smilie

-iain