Hi guys,

I have implemented a comet servlet that implements CometProcessor. I have
tested it and seems to work fine. The problem is that now I'm trying to
interact with it through an old system that used to use
ObjectInputStream/ObjectOutputStream classes. So i found a couple of issues
that probably are my fault but would like to know if any knows a solution
for these.

First of all something I found that I don't really care about too much is
that it seems that a flush doesn't sends the message at all.

OutputStream output = conn.getOutputStream();
Writer writer = new OutputStreamWriter(output, ENCODING);
writer.write("this is a request");
writer.flush();
writer.close();

So, for example this code doesn't send the message until I close the client
application.


Second is when I open a new input stream I always receive an exception. The
code:

InputStream input = conn.getInputStream();
objectInput = new ObjectInputStream(input);

And the exception:

java.io.StreamCorruptedException: invalid stream header
   at java.io.ObjectInputStream.readStreamHeader (ObjectInputStream.java
:764)
   at java.io.ObjectInputStream.<init>(ObjectInputStream.java:277)
   at com.cognotec.streaming.StreamTestClient.run(StreamTestClient.java:78)

This is my old connection set up. I don't think it should affect the test.

URL servletURL = new URL(url);
URLConnection conn = servletURL.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setUseCaches(false);
conn.setAllowUserInteraction(false);
conn.setRequestProperty ("Content-type", "text/plain");
conn.setRequestProperty("connection", "Keep-Alive");

Any suggestions?

Thanks for your help,
Martin

Reply via email to