views:

1646

answers:

4

Hi Folks,

I have an application with client server architecture. The client use Java Web Start with Java Swing / AWT and the sert uses HTTP server / Servlet with Tomcat. The communication is made from the serialization of objects, create a ObjectOutput serializes a byte array and send to the server respectively called the ObjectInputStream and deserializes.

The application follows communicating correctly to a certain time of concurrency where starting to show error "SocketException read timeout". The erro happens when the server invoke the method ObjectInputStream.getObject() in my servlet doPost method.

The tomcat will come slow and the errors start to decrease server response time until the crash time where i must restart the server and after everything works.

Someone went through this problem ?

+1  A: 

You haven't given us much information to go on, especially about the client side. But my suspicion is that the client side is:

  • failing to setting the Content-length header (or setting it to the wrong value),
  • failing to flush the output stream, and/or
  • not closing the output side of the socket.
Stephen C
A: 

Code

Client Code

        URLConnection conn =  url.openConnection();
        conn.setDoOutput(true);

        OutputStream os = conn.getOutputStream();
        ObjectOutputStream oss = new ObjectOutputStream(os);

        oss.writeUTF("protocol header sample");

        oss.writeObject(_parameters);
        oss.flush();
        oss.close();

Server Code

ObjectInputStream input = new ObjectInputStream(_request
                .getInputStream());
String method = input.readUTF();

parameters = input.readObject();

input.readObject() is a erro line of code

Rafael Soto
A: 

Is the amount of time that passes before the SocketException 20 mins or longer? (if I recall the standard amount of time a tcp/ip socket will wait before it times out if there is no connect activity) ? After all the Exception is telling you "read timeout" also might this have something to do with asynchronous nature of the web?

Wintermute
A: 

It's a tcp linux parameter? Like buffer mem size, max open files or other?

Rafael Soto