Welcome to the "trac"-ing site of http-access2!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Ticket #30 (closed enhancement: fixed)

Opened 3 years ago

Last modified 1 year ago

timeout is caused when '0'-sized chunk read

Reported by: nahi Assigned to: nahi
Priority: highest Milestone: 2.0.7
Component: core Version: 2.0
Keywords: Cc:

Description

(from soap4r ML)

All,

I'm running soap4r 1.5.5 with http-access2 2.0.6 over Ruby 1.8.2 on a Windows platform. 

When I invoke a web service that returns 'chunked' output, my client side sits a while and then times out.  A bit farther down in this mail there's a wiredump of the timeout, with a few extra bits, showing the problem.

The timeout is caused by a failure on my client side.  HTTPAccess2::Session reads all of the available chunks, fails to realize that everything has been read, and then does one more read.  The server doesn't respond to this extra read and the client eventually times out.  I've fixed this problem locally by adding the code in green.

Can anyone give me some feedback on this fix?  It surprises me that I'm even having this problem and I'm worried that.... well, actually, I worry about everything.  :-)

Thanks in advance for your thoughts,
Sandi

********** FIX ***************
require 'http-access2'
module HTTPAccess2
  class Session
    alias orig_read_body_chunked read_body_chunked
    def read_body_chunked
      data = orig_read_body_chunked
       
        #If the last attempt didn't get any data, close the socket to prevent trying again.
        #After the socket is closed, eof? will return true and get_data will no longer
        #attempt another read.
      @socket.close if data.size == 0
      data
    end
  end
end

********** Wire dump of timeout***************
= Request

! CONNECT TO a.b.c:446
! CONNECTION ESTABLISHED
POST /app-s2s-server/services/ApplicantIntegrationSoapPort HTTP/1.1

SOAPAction: ""

Content-Type: text/xml; charset=utf-8

User-Agent: SOAP4R/1.5.5 (/114, ruby 1.8.2 (2004-12-25) [i386-mswin32])

Date: Tue Nov 29 15:58:01 Eastern Standard Time 2005

Content-Length: 489

Host: a.b.c:446

<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <env:Body>
    <GetOpportunityListRequest xmlns="http://apply.grants.gov/WebServices/ApplicantIntegrationServices-V1.0"><OpportunityID></OpportunityID><CFDANumber>00.000</CFDANumber><CompetitionID></CompetitionID></GetOpportunityListRequest>
  </env:Body>
</env:Envelope>

= Response

HTTP/1.1 200 OK

Date: Tue, 29 Nov 2005 20:58:04 GMT

Server: WebLogic Server 7.0 SP5 Wed Mar 31 23:12:50 PST 2004 363281 with CR194073 CR184612

Content-Type: text/xml; charset=utf-8

Transfer-Encoding: chunked


*** In get_data until eof? loop, eof? =
*** Start of read_body_chunked
0fe8
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
--SNIP boring details--
*** End of read_body_chunked before return data, data.size = 4072

*** In get_data until eof? loop, eof? =
*** Start of read_body_chunked
04cb
instructions.pdf</InstructionURL></OpportunityInformation><OpportunityInformation><OpportunityID>APP-S2S-TEST-RR</OpportunityID><OpportunityTitle>R&amp;R
--SNIP boring details--
</GetOpportunityListResponse></soapenv:Body></soapenv:Envelope>
*** End of read_body_chunked before return data, data.size = 1227

*** In get_data until eof? loop, eof? =
*** Start of read_body_chunked
0000
*** End of read_body_chunked before return data, data.size = 0

*** In get_data until eof? loop, eof? =
*** Start of read_body_chunked
C:/ruby/lib/ruby/1.8/timeout.rb:42:in `fill_rbuff': execution expired (Timeout::Error)
    from C:/ruby/lib/ruby/site_ruby/1.8/openssl/buffering.rb:75:in `gets'
    from C:/ruby/lib/ruby/site_ruby/1.8/http-access2.rb:1041:in `gets'
    from C:/ruby/lib/ruby/site_ruby/1.8/http-access2.rb:1554:in `read_body_chunked'
    from C:/ruby/lib/ruby/site_ruby/1.8/http-access2.rb:1508:in `read_body'
    from C:/ruby/lib/ruby/site_ruby/1.8/http-access2.rb:1304:in `get_data'
    from C:/ruby/lib/ruby/site_ruby/1.8/http-access2.rb:1303:in `timeout'
    from C:/ruby/lib/ruby/1.8/timeout.rb:55:in `timeout'
    from C:/ruby/lib/ruby/site_ruby/1.8/http-access2.rb:1303:in `get_data'
     ... 23 levels...

********** Wire dump after fix***************
= Request

! CONNECT TO a.b.c:446
! CONNECTION ESTABLISHED
POST /app-s2s-server/services/ApplicantIntegrationSoapPort HTTP/1.1

SOAPAction: ""

Content-Type: text/xml; charset=utf-8

User-Agent: SOAP4R/1.5.5 (/114, ruby 1.8.2 (2004-12-25) [i386-mswin32])

Date: Tue Nov 29 16:12:52 Eastern Standard Time 2005

Content-Length: 489

Host: a.b.c:446

<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <env:Body>
    <GetOpportunityListRequest xmlns="http://apply.grants.gov/WebServices/ApplicantIntegrationServices-V1.0"><OpportunityID></OpportunityID><CFDANumber>00.000</CFDANumber><CompetitionID></CompetitionID></GetOpportunityListRequest>
  </env:Body>
</env:Envelope>

= Response

HTTP/1.1 200 OK

Date: Tue, 29 Nov 2005 21:12:55 GMT

Server: WebLogic Server 7.0 SP5 Wed Mar 31 23:12:50 PST 2004 363281 with CR194073 CR184612

Content-Type: text/xml; charset=utf-8

Transfer-Encoding: chunked

*** In get_data until eof? loop, eof? =
*** Start of read_body_chunked
0fe8
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><GetOpportunityListResponse
--SNIP boring details--
 *** End of read_body_chunked before return data, data.size = 4072

*** In get_data until eof? loop, eof? =
*** Start of read_body_chunked
04cb
--SNIP boring details--
</OpportunityInformation></GetOpportunityListResponse></soapenv:Body></soapenv:Envelope>
*** End of read_body_chunked before return data, data.size = 1227

*** In get_data until eof? loop, eof? =
*** Start of read_body_chunked
0000
*** End of read_body_chunked before return data, data.size = 0
! CONNECTION CLOSED

Change History

05/30/06 11:45:59 changed by kkkkoaaa

Keep a good job up! http://quick-adult-links.com

07/17/06 13:04:30 changed by nahi

  • type set to defect.
  • milestone changed from undefined to 2.0.7.

04/28/07 23:24:16 changed by nahi

  • status changed from new to closed.
  • type changed from defect to enhancement.
  • resolution set to fixed.

#132 should fixed ths problem. WebLogic? Server 7.0 SP5 must return "0\r\n" as a last-chunk instead of "0000\r\n" according to the spec.

I changed http-access2 to allow "0000\r\n" as a last-chunk for a workaround.