The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Read XML from Internet Hang

Hi everyone, I'm a bit new in Java.

I have the following code which will read a php responded XML file.
It's running under a timer in 10 seconds (for checking a message from server)
Everything is OK when the Internet line smooth, When the internet line disconnected, some this it's return error but still OK because it's going back to normal when the Internet line resume.

But sometime when the Internet line not so smooth, The request will just hanging over there, including the timer also not moving untill you have to use "alt-Ctrl Delete" to end the entire application.

Re: Read XML from Internet Hang

Hi Json,
I already try the normal urlConnection as given above and i set the timeout to 2000 milisecond.
I still face the same problem, my internet connection not stable, whenever the internet line slow of disconnected, the connection keep waiting and hang!

by the way my application is actually pulling a message from an internet web (apache) server for any event happen. This pulling is running in a timer, initially i set the time to 10 second, I did increase the timer to 15 seconds but the connection hang still happen! any idea?