tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sol myr <>
Subject Re: Comet and multipart
Date Tue, 04 Jan 2011 08:26:29 GMT
Filip, thanks for your reply.
You are correct that the server simply writes data, which we can format any way we like.
However, we were wondering whether Tomcat has any utilities/configurations to make it easier.

1) If we use multipart format (to separate between messages), does Tomcat/Apache have utilities
to make it easier? Or should we hand-code the appropriate headers, separators, etc?

2) If we rely on "Content-length:" (to tell when one message ends and another begins), this
header is usually automatically managed by Tomcat, so we'd have to ask Tomcat to manage it
differently (otherwise, it might calculate one "content-length" for all messages put together,
or it might omit it altogether and use "chunked" instead - which is also be an option, but
then how do we tell tomcat to have a chunk per message).

Thanks again

--- On Mon, 1/3/11, Filip Hanik - Dev Lists <> wrote:

From: Filip Hanik - Dev Lists <>
Subject: Re: Comet and multipart
To: "Tomcat Users List" <>
Date: Monday, January 3, 2011, 8:47 AM

On 1/3/2011 7:48 AM, sol myr wrote:
> Hi,
> We're implementing a CometServlet on top of Tomcat NIO connector, using "long polling".
> Currently we're using the approach recommended by most tutorials: the client opens a
connection and waits for a message (for a configured timeout); if such a message arrives,
the client consumes it (e.g. presents it on screen), then *closes* the http connection, and
opens a new connection (to wait for the next message).
> Unfortunately, we have a network performance problem with opening and closing connections
(our 3rd party proxy is good at keeping connections alive, but is slow in negotiating new
> So we'd like to keep the HTTP connection alive, and pass multiple messages on the same
connection. We were hoping to tell the messages apart based on multipart format, or some other
separator, or content length.
> Could anyone please tell whether that's supported on the TomcatServlet side?

yes, it is supported, as long as your client knows how to do it. On the server/servlet side,
all you do is read the input stream byte by byte
you can create any type of protocol rules inside the HTTP message that it sends up

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message