Bug 51515 - Comet over HTTPS: END event recieved immeidately for the first few times
Comet over HTTPS: END event recieved immeidately for the first few times
Status: RESOLVED FIXED
Product: Tomcat 6
Classification: Unclassified
Component: Connectors
6.0.20
PC Linux
: P2 major (vote)
: default
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2011-07-15 21:59 UTC by Sudeep Pradhan
Modified: 2011-08-16 10:18 UTC (History)
0 users



Attachments
Source in TomcatCometHttps.tar.gz and conf in server-conf.tar.gz packaged in the uploaded tar.gz (343.19 KB, application/x-gzip)
2011-07-15 21:59 UTC, Sudeep Pradhan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sudeep Pradhan 2011-07-15 21:59:52 UTC
Created attachment 27291 [details]
Source in TomcatCometHttps.tar.gz and conf in server-conf.tar.gz packaged in the uploaded tar.gz

I am  using Tomcat 6.0.20 on Ubuntu 10.04 and have written a simple TomcatWeatherServlet as presented in http://www.ibm.com/developerworks/web/library/wa-cometjava/ I modified the servlet to stream weather feed to multiple curl clients. I am using curl 7.21.6 as my client.

When I run curl -i -k -v -trace https://<IP_Addr>:8443/Weather from the command-line I get the following response for the first few times:

<code>
$ curl -i -k -v -trace https://<IP_Addr>:8443/Weather
* About to connect() to <IP_Addr> port 8443 (#0)
*   Trying <IP_Addr>... connected
* Connected to <IP_Addr> (<IP_Addr>) port 8443 (#0)
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using DHE-RSA-AES256-SHA
* Server certificate:
*              subject: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*              start date: 2009-02-23 23:07:18 GMT
*              expire date: 2019-02-21 23:07:18 GMT
*              common name: XXXXXXXXXX (does not match '<IP_Addr>')
*              issuer: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*              SSL certificate verify result: self signed certificate (18), continuing anyway.
> GET /Weather HTTP/1.1
> User-Agent: curl/7.21.6 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
> Host: <IP_Addr>:8443
> Accept: */*
> 
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
Server: Apache-Coyote/1.1
< Content-Length: 0
Content-Length: 0
< Date: Wed, 29 Jun 2011 23:40:17 GMT
Date: Wed, 29 Jun 2011 23:40:17 GMT

< 
* Connection #0 to host <IP_Addr> left intact
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):
</code>

Observe that Content-Length is 0 in the response. Also when I do get the expected response which is,

<code>
> GET /Weather HTTP/1.1
> User-Agent: curl/7.21.6 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
> Host: <IP_Addr>:8443
> Accept: */*
> 
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
Server: Apache-Coyote/1.1
< Transfer-Encoding: chunked
Transfer-Encoding: chunked
< Date: Wed, 29 Jun 2011 23:46:18 GMT
Date: Wed, 29 Jun 2011 23:46:18 GMT

< 
<h2>Conditions for San Jose, CA at 3:52 pm PDT</h2>
<img src="http://l.yimg.com/a/i/us/we/52/30.gif"/><br />
<b>Current Conditions:</b><br />
Partly Cloudy, 68 F<BR />
<BR /><b>Forecast:</b><BR />
Wed - Mostly Clear. High: 70 Low: 55<br />
Thu - Partly Cloudy. High: 77 Low: 57<br />
<br />
<a href="http://us.rd.yahoo.com/dailynews/rss/weather/San_Jose__CA/*http://weather.yahoo.com/forecast/USCA0993_f.html">Full Forecast at Yahoo! Weather</a><BR/><BR/>
(provided by <a href="http://www.weather.com" >The Weather Channel</a>)<br/>
<br>

</code>
I get Transfer-Encoding as chunked and no Content-Length.

On Server logs I get for the error are:
16:40:16.916  INFO http-8443-exec-3 TomcatWeatherServlet:41 - Begin for session: BDD6B1808161F1DA99D5D3207F1A719B
16:40:16.959  INFO http-8443-exec-4 TomcatWeatherServlet:48 - End for session: BDD6B1808161F1DA99D5D3207F1A719B
16:40:17.033  INFO http-8443-exec-4 TomcatWeatherServlet:48 - End for session: BDD6B1808161F1DA99D5D3207F1A719B

This was working when I was on HTTP. I have tried to debug this for a lot of time w/o success. Also I get two END events instead of one as seen in the Logs. 

Find the attached source and configuration
Comment 1 Mark Thomas 2011-07-22 12:59:26 UTC
I have tested this with the latest Tomcat 7.0.x code and it works as expected.

A couple of notes for folks trying to use this test case.
1. It assumes it is running from within VMware's internal network so (unless you fancy changing employers) you'll need to remove the proxy info from Weatherman.java
2. It has a couple of dependencies you can just remove rather than spend time tracking down.

If testing on Tomcat 7, remember that the Comet classes moved packages.

On to testing with the latest 6.0.x
Comment 2 Mark Thomas 2011-07-22 13:34:27 UTC
OK, I do see errors on first access (although not quite the same) on 6.0.x. I'm investigating now. In the meantime, an upgrade to 7.0.19 should fix this for you.
Comment 3 Mark Thomas 2011-07-22 17:33:26 UTC
I have a patch that fixes this for 6.0.x. I have proposed this patch for the next 6.0.x release.
Comment 4 Sudeep Pradhan 2011-08-04 00:28:00 UTC
Mark,

Can I have the patch so that I can test it?

Thanks,
Sudeep
Comment 5 Konstantin Kolinko 2011-08-04 04:06:50 UTC
(In reply to comment #4)
> Can I have the patch so that I can test it?

See STATUS.txt in the root of tc6.0.x source tree. A patch was "proposed" means that it has been added to the status file.
Comment 6 Sudeep Pradhan 2011-08-04 18:23:28 UTC
The patch fixes the problem mentioned in the bug.

There is another problem, END event is not raised when the client closes the connection abruptly. e.g. Ctrl-C on terminal running curl http client.

Is this another bug?
Comment 7 Mark Thomas 2011-08-16 10:18:01 UTC
Fixed in 6.0.x and will be included in 6.0.33 onwards.