You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by FelixG <wr...@googlemail.com> on 2007/07/27 17:09:51 UTC

COMET - Delays in output

Hi,
I'm trying to implement the comet code-example from the Tomcat
documentation,
using Tomcat 6.0.13, Http11NioProtocol is working and my servlet is
implementing CometProcessor.
I am trying to write into the response's PrintWriter with this code in
event():

if (event.getEventType() == CometEvent.EventType.BEGIN) {
  PrintWriter writer = response.getWriter();
  writer.println("<!doctype html public \"-//w3c//dtd html 4.0
transitional//en\">");
  writer.println("<head><title>Chat Servlet</title></head>" +
  "<body bgcolor=\"#FFFFFF\">" + new Date()+ "");
writer.flush();
}
...

At this point I am experiencing a delay according to the value of the
comet.timeout parameter
before the data is actually arriving at the client (even though flush()
should send it immediately).
Could someone please point me to an explanation of this behavior?

Regards,
felix
-- 
View this message in context: http://www.nabble.com/COMET---Delays-in-output-tf4158481.html#a11831204
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: COMET - Delays in output

Posted by john x <lo...@gmail.com>.
It seems must send enough bytes of data to client .
try add this code to before you write
for(int j=0;j<500;j++){
      writer.println(" ");
     }
By the way ,do you try the example of tomcat6.0.13 comet "chat "
when I try to login ,the session always comes error ,it never happen in
tomcat6.0.10

2007/7/30, FelixG <wr...@googlemail.com>:
>
>
> I'm testing in Eclipse/WinXP locally and on a solaris8 machine over a
> local
> network. The delay
> is occuring on both Tomcats.
>
>
> Sebastiaan van Erk wrote:
> >
> > What kind of environment are you testing in? Does the servlet run on
> > your local development machine or over the network. Are there possibly
> > transparent proxies between the two endpoints? You could try testing
> > with network tools such as netcat to debug what's happening.
> >
> > Regards,
> > Sebastiaan
> >
> > FelixG wrote:
> >> Hi,
> >> I'm trying to implement the comet code-example from the Tomcat
> >> documentation,
> >> using Tomcat 6.0.13, Http11NioProtocol is working and my servlet is
> >> implementing CometProcessor.
> >> I am trying to write into the response's PrintWriter with this code in
> >> event():
> >>
> >> if (event.getEventType() == CometEvent.EventType.BEGIN) {
> >>   PrintWriter writer = response.getWriter();
> >>   writer.println("<!doctype html public \"-//w3c//dtd html 4.0
> >> transitional//en\">");
> >>   writer.println("<head><title>Chat Servlet</title></head>" +
> >>   "<body bgcolor=\"#FFFFFF\">" + new Date()+ "");
> >> writer.flush();
> >> }
> >> ...
> >>
> >> At this point I am experiencing a delay according to the value of the
> >> comet.timeout parameter
> >> before the data is actually arriving at the client (even though flush()
> >> should send it immediately).
> >> Could someone please point me to an explanation of this behavior?
> >>
> >> Regards,
> >> felix
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/COMET---Delays-in-output-tf4158481.html#a11860031
> Sent from the Tomcat - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: COMET - Delays in output

Posted by Sebastiaan van Erk <se...@sebster.com>.
FelixG wrote:
>  I'm testing in Eclipse/WinXP locally and on a solaris8 machine over a local
> network. The delay
> is occuring on both Tomcats.

Ok, locally at least you shouldn't be experiencing any proxy hinder. :-)

The flush should immediately push the data to the client. Did you try 
using netcat or telnet to make sure the problem is really on the server 
side?

C:\> telnet localhost 8080
GET /app/MyServlet HTTP/1.0<enter>
<enter>

and you should get part of the response. You can do fancier HTTP/1.1 
requests to, but then it is easiest to capture the request headers the 
way your browser would send them. With firefox the tamper data plugin 
allows you to see the exact request (so you can try it outside of a 
browser).

Regards,
Sebastiaan

> 
> Sebastiaan van Erk wrote:
>> What kind of environment are you testing in? Does the servlet run on 
>> your local development machine or over the network. Are there possibly 
>> transparent proxies between the two endpoints? You could try testing 
>> with network tools such as netcat to debug what's happening.
>>
>> Regards,
>> Sebastiaan
>>
>> FelixG wrote:
>>> Hi,
>>> I'm trying to implement the comet code-example from the Tomcat
>>> documentation,
>>> using Tomcat 6.0.13, Http11NioProtocol is working and my servlet is
>>> implementing CometProcessor.
>>> I am trying to write into the response's PrintWriter with this code in
>>> event():
>>>
>>> if (event.getEventType() == CometEvent.EventType.BEGIN) {
>>>   PrintWriter writer = response.getWriter();
>>>   writer.println("<!doctype html public \"-//w3c//dtd html 4.0
>>> transitional//en\">");
>>>   writer.println("<head><title>Chat Servlet</title></head>" +
>>>   "<body bgcolor=\"#FFFFFF\">" + new Date()+ "");
>>> writer.flush();
>>> }
>>> ...
>>>
>>> At this point I am experiencing a delay according to the value of the
>>> comet.timeout parameter
>>> before the data is actually arriving at the client (even though flush()
>>> should send it immediately).
>>> Could someone please point me to an explanation of this behavior?
>>>
>>> Regards,
>>> felix
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
> 

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: COMET - Delays in output

Posted by FelixG <wr...@googlemail.com>.
 I'm testing in Eclipse/WinXP locally and on a solaris8 machine over a local
network. The delay
is occuring on both Tomcats.


Sebastiaan van Erk wrote:
> 
> What kind of environment are you testing in? Does the servlet run on 
> your local development machine or over the network. Are there possibly 
> transparent proxies between the two endpoints? You could try testing 
> with network tools such as netcat to debug what's happening.
> 
> Regards,
> Sebastiaan
> 
> FelixG wrote:
>> Hi,
>> I'm trying to implement the comet code-example from the Tomcat
>> documentation,
>> using Tomcat 6.0.13, Http11NioProtocol is working and my servlet is
>> implementing CometProcessor.
>> I am trying to write into the response's PrintWriter with this code in
>> event():
>> 
>> if (event.getEventType() == CometEvent.EventType.BEGIN) {
>>   PrintWriter writer = response.getWriter();
>>   writer.println("<!doctype html public \"-//w3c//dtd html 4.0
>> transitional//en\">");
>>   writer.println("<head><title>Chat Servlet</title></head>" +
>>   "<body bgcolor=\"#FFFFFF\">" + new Date()+ "");
>> writer.flush();
>> }
>> ...
>> 
>> At this point I am experiencing a delay according to the value of the
>> comet.timeout parameter
>> before the data is actually arriving at the client (even though flush()
>> should send it immediately).
>> Could someone please point me to an explanation of this behavior?
>> 
>> Regards,
>> felix
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/COMET---Delays-in-output-tf4158481.html#a11860031
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: COMET - Delays in output

Posted by Sebastiaan van Erk <se...@sebster.com>.
What kind of environment are you testing in? Does the servlet run on 
your local development machine or over the network. Are there possibly 
transparent proxies between the two endpoints? You could try testing 
with network tools such as netcat to debug what's happening.

Regards,
Sebastiaan

FelixG wrote:
> Hi,
> I'm trying to implement the comet code-example from the Tomcat
> documentation,
> using Tomcat 6.0.13, Http11NioProtocol is working and my servlet is
> implementing CometProcessor.
> I am trying to write into the response's PrintWriter with this code in
> event():
> 
> if (event.getEventType() == CometEvent.EventType.BEGIN) {
>   PrintWriter writer = response.getWriter();
>   writer.println("<!doctype html public \"-//w3c//dtd html 4.0
> transitional//en\">");
>   writer.println("<head><title>Chat Servlet</title></head>" +
>   "<body bgcolor=\"#FFFFFF\">" + new Date()+ "");
> writer.flush();
> }
> ...
> 
> At this point I am experiencing a delay according to the value of the
> comet.timeout parameter
> before the data is actually arriving at the client (even though flush()
> should send it immediately).
> Could someone please point me to an explanation of this behavior?
> 
> Regards,
> felix

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: COMET - Delays in output

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
FelixG wrote:
> After looking at the TCP packets I can say this:
> The use of flush() in COMET *does* push data-packets immediately to the
> client, but it seems that
> the client (in my case a browser) doesn't recognize/display them until the
> outputstream is closed 
> due to an ERROR/TIMEOUT or until I call close() manually for the stream.
>   
yes, the browser doesn't really know what to do with the request until 
the response is complete

Filip
> felix
>
>
> Filip Hanik - Dev Lists wrote:
>   
>>  
>> flush should push out the data for you. If not, please open a bugzilla 
>> item and attach the test case
>> http://issues.apache.org/bugzilla/enter_bug.cgi?product=Tomcat%206
>>
>> Filip
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
>>     
>
>   



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: COMET - Delays in output

Posted by FelixG <wr...@googlemail.com>.
After looking at the TCP packets I can say this:
The use of flush() in COMET *does* push data-packets immediately to the
client, but it seems that
the client (in my case a browser) doesn't recognize/display them until the
outputstream is closed 
due to an ERROR/TIMEOUT or until I call close() manually for the stream.

felix


Filip Hanik - Dev Lists wrote:
> 
>  
> flush should push out the data for you. If not, please open a bugzilla 
> item and attach the test case
> http://issues.apache.org/bugzilla/enter_bug.cgi?product=Tomcat%206
> 
> Filip
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/COMET---Delays-in-output-tf4158481.html#a11941558
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: COMET - Delays in output

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
FelixG wrote:
> Hi,
> I'm trying to implement the comet code-example from the Tomcat
> documentation,
> using Tomcat 6.0.13, Http11NioProtocol is working and my servlet is
> implementing CometProcessor.
> I am trying to write into the response's PrintWriter with this code in
> event():
>
> if (event.getEventType() == CometEvent.EventType.BEGIN) {
>   PrintWriter writer = response.getWriter();
>   writer.println("<!doctype html public \"-//w3c//dtd html 4.0
> transitional//en\">");
>   writer.println("<head><title>Chat Servlet</title></head>" +
>   "<body bgcolor=\"#FFFFFF\">" + new Date()+ "");
> writer.flush();
> }
>   
flush should push out the data for you. If not, please open a bugzilla 
item and attach the test case
http://issues.apache.org/bugzilla/enter_bug.cgi?product=Tomcat%206

Filip
> ...
>
> At this point I am experiencing a delay according to the value of the
> comet.timeout parameter
> before the data is actually arriving at the client (even though flush()
> should send it immediately).
> Could someone please point me to an explanation of this behavior?
>
> Regards,
> felix
>   


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: COMET - Delays in output

Posted by john x <lo...@gmail.com>.
Can you run the  comet code-example "chat" success?
I tried many times ,it don't work in tomcat6.0.13
I just try straight the url
http://localhost:8080/examples/jsp/chat/login.jsp
and also modify the server.xml ,change the protocol by "
org.apache.coyote.http11.Http11NioProtocol"
Are there other worksI did not do ?

And I also debug it, it seems there is something wrong when
execute the line
            "response.sendRedirect("post.jsp");"
the page *login.jsp* just stop util the comet session time out,then the page
rediect to *post.jsp*
**
everybody help me ,thanks
regards.
john
2007/7/27, FelixG <wr...@googlemail.com>:
>
>
> Hi,
> I'm trying to implement the comet code-example from the Tomcat
> documentation,
> using Tomcat 6.0.13, Http11NioProtocol is working and my servlet is
> implementing CometProcessor.
> I am trying to write into the response's PrintWriter with this code in
> event():
>
> if (event.getEventType() == CometEvent.EventType.BEGIN) {
> PrintWriter writer = response.getWriter();
> writer.println("<!doctype html public \"-//w3c//dtd html 4.0
> transitional//en\">");
> writer.println("<head><title>Chat Servlet</title></head>" +
> "<body bgcolor=\"#FFFFFF\">" + new Date()+ "");
> writer.flush();
> }
> ...
>
> At this point I am experiencing a delay according to the value of the
> comet.timeout parameter
> before the data is actually arriving at the client (even though flush()
> should send it immediately).
> Could someone please point me to an explanation of this behavior?
>
> Regards,
> felix
> --
> View this message in context:
> http://www.nabble.com/COMET---Delays-in-output-tf4158481.html#a11831204
> Sent from the Tomcat - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>