Archived Forum Post

Index of archived forum posts

Question:

SynchronousRequest invoked many times

Apr 30 '13 at 12:44

Hi,

today debugging my app with Http module (9.4.1 .net 32 bit) I discovered strange problem with some urls, when I invoke

_http.SynchronousRequest(_uri.Host, _uri.Port, _uri.Scheme == Uri.UriSchemeHttps, _req);

it's doing 4 times the same POST request and response is null and I don't know why. On other urls everything works good. GET requests is working fine.

I only discover "Actual content-length not equal to calculated content-length" in LastError

---- Sending ----
GET http://arakecity.com/join HTTP/1.1
Accept: */*
Accept-Encoding: gzip
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Language: en-us,en;q=0.5
User-Agent: Mozilla/5.0 (X11; U; Linux amd64; rv:5.0) Gecko/20100101 Firefox/5.0 (Debian)
Cookie: a9e1bf69da24f7c65cf9bafd6fa49672=con4guctovgqjr04tceckrpo41; base_language_id=27
Host: arakecity.com
Connection: Keep-Alive

---- Received ----
HTTP/1.1 200 OK
Date: Fri, 19 Apr 2013 21:16:26 GMT
Server: Apache/2
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: base_language_id=27; expires=Sun, 19-May-2013 21:16:27 GMT; path=/
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
Content-Length: 6064
Keep-Alive: timeout=1, max=98
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8

---- Sending ----
GET http://arakecity.com/base/captcha/index/ HTTP/1.1
Accept: */*
Accept-Encoding: gzip
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Language: en-us,en;q=0.5
Referer: http://arakecity.com/join
User-Agent: Mozilla/5.0 (X11; U; Linux amd64; rv:5.0) Gecko/20100101 Firefox/5.0 (Debian)
Cookie: a9e1bf69da24f7c65cf9bafd6fa49672=con4guctovgqjr04tceckrpo41; base_language_id=27
Host: arakecity.com
Connection: Keep-Alive

---- Received ----
HTTP/1.1 200 OK
Date: Fri, 19 Apr 2013 21:16:31 GMT
Server: Apache/2
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: base_language_id=27; expires=Sun, 19-May-2013 21:16:31 GMT; path=/
Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
Content-Length: 3238
Keep-Alive: timeout=1, max=100
Connection: Keep-Alive
Content-Type: image/png

Problem starts here:

---- Sending ----
POST http://arakecity.com/join HTTP/1.1
Cookie: a9e1bf69da24f7c65cf9bafd6fa49672=con4guctovgqjr04tceckrpo41; base_language_id=27
Referer: http://arakecity.com/join
User-Agent: Mozilla/5.0 (X11; U; Linux amd64; rv:5.0) Gecko/20100101 Firefox/5.0 (Debian)
Accept: application/xml,application/xhtml+xml,text/html;
    q="0.9,text/plain";q="0.8,image/png,*/*"; q="0.5"
Host: arakecity.com
Content-Type: multipart/form-data; boundary=------------040509010502010903010008
Content-Length: 6683

--------------040509010502010903010008
Content-Disposition: form-data; name="form_name"

joinForm
--------------040509010502010903010008
Content-Disposition: form-data; name="birthdate"

1981/2/20
--------------040509010502010903010008
Content-Disposition: form-data; name="year_birthdate"

1981
--------------040509010502010903010008
Content-Disposition: form-data; name="month_birthdate"

... and more

POST http://arakecity.com/join HTTP/1.1
Cookie: a9e1bf69da24f7c65cf9bafd6fa49672=con4guctovgqjr04tceckrpo41; base_language_id=27
Referer: http://arakecity.com/join
User-Agent: Mozilla/5.0 (X11; U; Linux amd64; rv:5.0) Gecko/20100101 Firefox/5.0 (Debian)
Accept: application/xml,application/xhtml+xml,text/html;
    q="0.9,text/plain";q="0.8,image/png,*/*"; q="0.5"
Host: arakecity.com
Content-Type: multipart/form-data; boundary=------------080706050306030806080108
Content-Length: 6683

--------------080706050306030806080108
Content-Disposition: form-data; name="form_name"

joinForm
--------------080706050306030806080108
Content-Disposition: form-data; name="birthdate"

1981/2/20
--------------080706050306030806080108
Content-Disposition: form-data; name="year_birthdate"

POST http://arakecity.com/join HTTP/1.1
Cookie: a9e1bf69da24f7c65cf9bafd6fa49672=con4guctovgqjr04tceckrpo41; base_language_id=27
Referer: http://arakecity.com/join
User-Agent: Mozilla/5.0 (X11; U; Linux amd64; rv:5.0) Gecko/20100101 Firefox/5.0 (Debian)
Accept: application/xml,application/xhtml+xml,text/html;
    q="0.9,text/plain";q="0.8,image/png,*/*"; q="0.5"
Host: arakecity.com
Content-Type: multipart/form-data; boundary=------------050405070402020703060906
Content-Length: 6683

--------------050405070402020703060906
Content-Disposition: form-data; name="form_name"

joinForm
--------------050405070402020703060906
Content-Disposition: form-data; name="birthdate"

1981/2/20
--------------050405070402020703060906
Content-Disposition: form-data; name="year_birthdate"

1981
--------------050405070402020703060906

LastError:

       ChilkatLog:
  SynchronousRequest:
    DllDate: Apr 16 2013
    ChilkatVersion: 9.4.1.4
    UnlockPrefix: XXX
    Username: XXX
    Architecture: Little Endian; 32-bit
    Language: .NET 4.0
    VerboseLogging: 0
    domain: arakecity.com
    port: 80
    ssl: 0
    RequestData:
      HttpVersion: 1.1
      Verb: POST
      Path: /join
      Charset: utf-8
      SendCharset: 0
      MimeHeader: Referer: http://arakecity.com/join
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b8pre) Gecko/20101114 Firefox/4.0b8pre
Accept: application/xml,application/xhtml+xml,text/html;
\tq=\"0.9,text/plain\";q=\"0.8,image/png,*/*\"; q=\"0.5\"
Content-Type: multipart/form-data
      RequestParams:
        RequestItem:
          name: form_name
          value: joinForm
        --RequestItem
        RequestItem:
          name: birthdate
          value: 1981/1/10
        --RequestItem
        RequestItem:
          name: year_birthdate
          value: 1981
        --RequestItem
        RequestItem:
          name: month_birthdate
          value: 1
        --RequestItem
        RequestItem:
          name: day_birthdate
          value: 10
        --RequestItem
        RequestItem:
          name: userPhoto
          fileOnDisk: XXX\\a.jpg
          numValueBytes: 0
        --RequestItem
        RequestItem:
          name: termOfUse
          value: on
        --RequestItem
        RequestItem:
          name: captchaField
          value: n7ehku
        --RequestItem
        RequestItem:
          name: joinSubmit
          value: ادامه
        --RequestItem
        RequestItem:
          name: realname
          value: Watts
        --RequestItem
        RequestItem:
          name: sex
          value: 1
        --RequestItem
        RequestItem:
          name: userPhoto
          value: 
        --RequestItem
      --RequestParams
    --RequestData
    ReadTimeout: 30
    ConnectTimeout: 20
    httpConnect:
      hostname: arakecity.com
      port: 80
      ssl: 0
      Need to establish connection to the HTTP server...
      proxyDomain: 127.0.0.1
      proxyPort: 8888
      ConnectTimeoutMs_1: 20000
      calling ConnectSocket2
      IPV6 enabled connect with NO heartbeat.
      This is an IPV4 numeric address...
      AddrInfoList:
        AddrInfo:
          ai_flags: 4
          ai_family: 2
          ai_socktype: 1
          ai_protocol: 0
          ai_addrlen: 16
          ai_canonname: (NULL)
        --AddrInfo
      --AddrInfoList
      Connect using IPV4.
      ipAddress1: 127.0.0.1
      myIP_3: 127.0.0.1
      myPort_3: 55407
      connect successful (2)
      Turning on TCP_NODELAY.
      socketOptions:
        SO_SNDBUF: 8192
        SO_RCVBUF: 8192
        TCP_NODELAY: 8193
      --socketOptions
      Connected
    --httpConnect
    connectTime1: Elapsed time: 0 millisec
    sendRequestGetResponse_1:
      sendRequest:
        Adding Host header...
        host: arakecity.com
        port: 80
        Auto-adding any accumulated cookies.
        CookieDir: memory
        CookieDomain: arakecity.com
        CookiePath: /join
        LoadCookieJar:
          Path: /join
          GetDomainCookiesXml:
            CookieDir: memory
            Domain: arakecity.com
            HashKey: arakecity_com.xml
          --GetDomainCookiesXml
        --LoadCookieJar
        AddingCookie: a9e1bf69da24f7c65cf9bafd6fa49672=8rb4gdh2gnus063uafkcad2v76; base_language_id=27
        generateUploadToOutput2:
          extraForProxy: http://arakecity.com
          targetPathForUpload: http://arakecity.com/join
          HttpStartLine: POST http://arakecity.com/join HTTP/1.1
          calculatedContentLength: 6683
          sendMultipartFormData:
            item:
              name: form_name
            --item
            item:
              name: birthdate
            --item
            item:
              name: year_birthdate
            --item
            item:
              name: month_birthdate
            --item
            item:
              name: day_birthdate
            --item
            item:
              name: userPhoto
              filename: XXX\\a.jpg
            --item
            item:
              name: termOfUse
            --item
            item:
              name: captchaField
            --item
            item:
              name: joinSubmit
            --item
            item:
              name: realname
            --item
            item:
              name: sex
            --item
            item:
              name: userPhoto
            --item
            actualContentLength: 6693
            Actual content-length not equal to calculated content-length.
          --sendMultipartFormData
        --generateUploadToOutput2
        Closing connection to HTTP server. (1)
        Failed to stream upload to output..
      --sendRequest
      sendRequestTime: Elapsed time: 15 millisec
      httpConnect:
        hostname: arakecity.com
        port: 80
        ssl: 0
        Need to establish connection to the HTTP server...
        proxyDomain: 127.0.0.1
        proxyPort: 8888
        ConnectTimeoutMs_1: 20000
        calling ConnectSocket2
        IPV6 enabled connect with NO heartbeat.
        This is an IPV4 numeric address...
        AddrInfoList:
          AddrInfo:
            ai_flags: 4
            ai_family: 2
            ai_socktype: 1
            ai_protocol: 0
            ai_addrlen: 16
            ai_canonname: (NULL)
          --AddrInfo
        --AddrInfoList
        Connect using IPV4.
        ipAddress1: 127.0.0.1
        myIP_3: 127.0.0.1
        myPort_3: 55408
        connect successful (2)
        Turning on TCP_NODELAY.
        socketOptions:
          SO_SNDBUF: 8192
          SO_RCVBUF: 8192
          TCP_NODELAY: 8193
        --socketOptions
        Connected
      --httpConnect
      connectTime5: Elapsed time: 0 millisec
      sendRequest:
        Auto-adding any accumulated cookies.
        CookieDir: memory
        CookieDomain: arakecity.com
        CookiePath: /join
        LoadCookieJar:
          Path: /join
          GetDomainCookiesXml:
            CookieDir: memory
            Domain: arakecity.com
            HashKey: arakecity_com.xml
          --GetDomainCookiesXml
        --LoadCookieJar
        AddingCookie: a9e1bf69da24f7c65cf9bafd6fa49672=8rb4gdh2gnus063uafkcad2v76; base_language_id=27
        generateUploadToOutput2:
          extraForProxy: http://arakecity.com
          targetPathForUpload: http://arakecity.com/join
          HttpStartLine: POST http://arakecity.com/join HTTP/1.1
          calculatedContentLength: 6683
          sendMultipartFormData:
            item:
              name: form_name
            --item
            item:
              name: birthdate
            --item
            item:
              name: year_birthdate
            --item
            item:
              name: month_birthdate
            --item
            item:
              name: day_birthdate
            --item
            item:
              name: userPhoto
              filename: XXX\\a.jpg
            --item
            item:
              name: termOfUse
            --item
            item:
              name: captchaField
            --item
            item:
              name: joinSubmit
            --item
            item:
              name: realname
            --item
            item:
              name: sex
            --item
            item:
              name: userPhoto
            --item
            actualContentLength: 6693
            Actual content-length not equal to calculated content-length.
          --sendMultipartFormData
        --generateUploadToOutput2
        Closing connection to HTTP server. (1)
        Failed to stream upload to output..
      --sendRequest
      sendRequestTime: Elapsed time: 0 millisec
    --sendRequestGetResponse_1
    Socket not writeable, re-opening connection with HTTP server (2)
    Closing connection to HTTP server. (2)
    httpConnect:
      hostname: arakecity.com
      port: 80
      ssl: 0
      Need to establish connection to the HTTP server...
      proxyDomain: 127.0.0.1
      proxyPort: 8888
      ConnectTimeoutMs_1: 20000
      calling ConnectSocket2
      IPV6 enabled connect with NO heartbeat.
      This is an IPV4 numeric address...
      AddrInfoList:
        AddrInfo:
          ai_flags: 4
          ai_family: 2
          ai_socktype: 1
          ai_protocol: 0
          ai_addrlen: 16
          ai_canonname: (NULL)
        --AddrInfo
      --AddrInfoList
      Connect using IPV4.
      ipAddress1: 127.0.0.1
      myIP_3: 127.0.0.1
      myPort_3: 55410
      connect successful (2)
      Turning on TCP_NODELAY.
      socketOptions:
        SO_SNDBUF: 8192
        SO_RCVBUF: 8192
        TCP_NODELAY: 8193
      --socketOptions
      Connected
    --httpConnect
    connectTime2: Elapsed time: 0 millisec
    sendRequestGetResponse_2:
      sendRequest:
        Auto-adding any accumulated cookies.
        CookieDir: memory
        CookieDomain: arakecity.com
        CookiePath: /join
        LoadCookieJar:
          Path: /join
          GetDomainCookiesXml:
            CookieDir: memory
            Domain: arakecity.com
            HashKey: arakecity_com.xml
          --GetDomainCookiesXml
        --LoadCookieJar
        AddingCookie: a9e1bf69da24f7c65cf9bafd6fa49672=8rb4gdh2gnus063uafkcad2v76; base_language_id=27
        generateUploadToOutput2:
          extraForProxy: http://arakecity.com
          targetPathForUpload: http://arakecity.com/join
          HttpStartLine: POST http://arakecity.com/join HTTP/1.1
          calculatedContentLength: 6683
          sendMultipartFormData:
            item:
              name: form_name
            --item
            item:
              name: birthdate
            --item
            item:
              name: year_birthdate
            --item
            item:
              name: month_birthdate
            --item
            item:
              name: day_birthdate
            --item
            item:
              name: userPhoto
              filename: XXX\\a.jpg
            --item
            item:
              name: termOfUse
            --item
            item:
              name: captchaField
            --item
            item:
              name: joinSubmit
            --item
            item:
              name: realname
            --item
            item:
              name: sex
            --item
            item:
              name: userPhoto
            --item
            actualContentLength: 6693
            Actual content-length not equal to calculated content-length.
          --sendMultipartFormData
        --generateUploadToOutput2
        Closing connection to HTTP server. (1)
        Failed to stream upload to output..
      --sendRequest
      sendRequestTime: Elapsed time: 16 millisec
      httpConnect:
        hostname: arakecity.com
        port: 80
        ssl: 0
        Need to establish connection to the HTTP server...
        proxyDomain: 127.0.0.1
        proxyPort: 8888
        ConnectTimeoutMs_1: 20000
        calling ConnectSocket2
        IPV6 enabled connect with NO heartbeat.
        This is an IPV4 numeric address...
        AddrInfoList:
          AddrInfo:
            ai_flags: 4
            ai_family: 2
            ai_socktype: 1
            ai_protocol: 0
            ai_addrlen: 16
            ai_canonname: (NULL)
          --AddrInfo
        --AddrInfoList
        Connect using IPV4.
        ipAddress1: 127.0.0.1
        myIP_3: 127.0.0.1
        myPort_3: 55411
        connect successful (2)
        Turning on TCP_NODELAY.
        socketOptions:
          SO_SNDBUF: 8192
          SO_RCVBUF: 8192
          TCP_NODELAY: 8193
        --socketOptions
        Connected
      --httpConnect
      connectTime5: Elapsed time: 0 millisec
      sendRequest:
        Auto-adding any accumulated cookies.
        CookieDir: memory
        CookieDomain: arakecity.com
        CookiePath: /join
        LoadCookieJar:
          Path: /join
          GetDomainCookiesXml:
            CookieDir: memory
            Domain: arakecity.com
            HashKey: arakecity_com.xml
          --GetDomainCookiesXml
        --LoadCookieJar
        AddingCookie: a9e1bf69da24f7c65cf9bafd6fa49672=8rb4gdh2gnus063uafkcad2v76; base_language_id=27
        generateUploadToOutput2:
          extraForProxy: http://arakecity.com
          targetPathForUpload: http://arakecity.com/join
          HttpStartLine: POST http://arakecity.com/join HTTP/1.1
          calculatedContentLength: 6683
          sendMultipartFormData:
            item:
              name: form_name
            --item
            item:
              name: birthdate
            --item
            item:
              name: year_birthdate
            --item
            item:
              name: month_birthdate
            --item
            item:
              name: day_birthdate
            --item
            item:
              name: userPhoto
              filename: XXX\\a.jpg
            --item
            item:
              name: termOfUse
            --item
            item:
              name: captchaField
            --item
            item:
              name: joinSubmit
            --item
            item:
              name: realname
            --item
            item:
              name: sex
            --item
            item:
              name: userPhoto
            --item
            actualContentLength: 6693
            Actual content-length not equal to calculated content-length.
          --sendMultipartFormData
        --generateUploadToOutput2
        Closing connection to HTTP server. (1)
        Failed to stream upload to output..
      --sendRequest
      sendRequestTime: Elapsed time: 0 millisec
    --sendRequestGetResponse_2
    totalTime: Elapsed time: 31 millisec
    Failed.
  --SynchronousRequest
--ChilkatLog

Accepted Answer

This new build should fix the problem:
http://www.chilkatsoft.com/preRelease/ChilkatDotNet4.zip


Answer

Internally, SynchronousRequest and other HTTP methods might respond to HTTP responses by sending a subsequent request as indicated by the response. For example, if the HTTP response is a redirect, or if it's a response that indicates authorization is required, such as w/ NTLM.

It's impossible to know what happened because you did not post the HTTP responses. You need to clearly post the sequence of requests and responses. (If there is bulk data within a request or response, that can and should be omitted.)

Also, the LastErrorText you posted is useless because you did not maintain the line-endings. Posting a long LastErrorText as a single line of text is not helpful.


Answer

I have updated LastErrorText to multilines (previous there was rn) In error text the error is "Actual content-length not equal to calculated content-length" and Chilkat library doing the same request many times

In previous post I don't HTTP Response because there is no response - HttpResponse is null. After POST Request is another POST Request and another - with no responses for them

Also I posted direclty when the bug exists - when using _req.ContentType = "multipart/form-data" (image upload) and non english characters in request params (for examples russian chars), directly when I post:

RequestItem:
          name: joinSubmit
          value: ادامه

wihtout joinSubmit or when it's value is "aaaa" everything works fine (or when I don't upload image ther is also ok)

I hope now all is good explained