powered by Jive Software

Java connection to server hangs, and resumes after openfire times out

Hi.

Dont know if this is the right place to post this, but I´ll give it a try.

I´m making a simple java connection to my openfire server. I can easily send xml strings to the server, so logging on and sending messages is no problem. But when i try to recieve something from the server, the java app. hangs, and when openfire times the connection out (after the default 5 mins), the app resumes.

I´m using

BufferedReader in;

in = new BufferedReader(new InputStreamReader(s.getInputStream()));

to recieve the messages, and if i try to

String s = in.readLine();

System.out.println(s);

then after openfire has closed the connection, the java console spits all the xml strings the server had sent out in one long string. Its like readLine() thinks its one long message it doesent know when to split up and post, and the only thing that can make it post the data it has recieved, is when the connection is terminated.

Its quite hard to describe the problem, but i hope you get it

If needed i can post the whole java app.

Thanks alot for your help and time.

Regards.

Hi,

it may help to use Smack as an XMPP client API.

I assume that “String s = in.readLine();” waits for a newline character but as Openfire does not send one this method blocks.

LG

Hi LG.

Thank you for the answer.

Yea, i had a feeling it was readLine who had a problem breaking the xml strings up.

Im not familiar with Smack, but I´ll look into it.

Thanks alot