Пока загрузка работает, но не отправлять запрос (Chilkat) - PullRequest
0 голосов
/ 16 апреля 2019

У меня очень запутанная проблема, и я потратил столько часов, чтобы найти проблему, но безуспешно: (

У меня настроен веб-сервер на моем мобильном (Android) ..

и пытаюсь использовать это, используя мое приложение vb

где я просто вызываю метод Download по самому образцу URL (тот же IP / порт), он работает и сохраняет тело ответа как загруженный файл.

но когда я пытаюсь отправить команду post, она не работает, выдает ошибку «Соединение отклонено»

код для загрузки:

objDHTTP.Download("http://192.168.1.101:8000/fileAdmin.php", strAppDir & "\wtf-response.txt")

вот код, когда я пытался использовать тот же URL и порт для почтового запроса:

objDRequest.Path = "/fileAdmin.php"
objDRequest.AddParam("fileAction", "Upload")
objDRequest.AddParam("fileName", "DB.sql")
objDRequest.AddFileForUpload("adminFile", strAppDir & "\c.dll")
objDResponse = objDHTTP.SynchronousRequest(strServerIP, 8000, False, objDRequest)

но не работает и выдает ошибку выше

вот ответ об успешном выполнении (для метода загрузки):

<ChilkatLog>
  <Download>
    <DllDate>Dec 21 2018</DllDate>
    <ChilkatVersion>9.5.0.76</ChilkatVersion>
    <Architecture>Little Endian; 32-bit</Architecture>
    <Language>.NET 4.0</Language>
    <VerboseLogging>0</VerboseLogging>
    <url>http://192.168.1.101:8000/fileAdmin.php</url>
    <toLocalPath>G:\wtf-sucess.txt</toLocalPath>
    <currentWorkingDir>G:\</currentWorkingDir>
    <a_httpDownload>
      <httpDownloadFile>
        <localFilePath>G:\wtf-sucess.txt</localFilePath>
        <localFileAlreadyExists>1</localFileAlreadyExists>
        <quickHttpRequest>
          <httpVerb>GET</httpVerb>
          <url>http://192.168.1.101:8000/fileAdmin.php</url>
          <openHttpConnection>
            <info>Opening connection directly to HTTP server.</info>
            <httpHostname>192.168.1.101</httpHostname>
            <httpPort>8000</httpPort>
            <tls>False</tls>
            <info>HTTP connection succeeded.</info>
          </openHttpConnection>
          <buildQuickRequest>
            <genStartLine>
              <startLine>GET /fileAdmin.php HTTP/1.1</startLine>
            </genStartLine>
            <addCookies>
              <info>Not auto-adding cookies.</info>
              <sendCookies>1</sendCookies>
              <cookieDir></cookieDir>
            </addCookies>
          </buildQuickRequest>
          <sendRequestHeader>
            <sendHeaderElapsedMs>0</sendHeaderElapsedMs>
          </sendRequestHeader>
          <statusCode>200</statusCode>
          <statusText>OK</statusText>
          <checkCloseConnection>
            <info>Response includes connection:close header (or proxy-connection:close header)</info>
          </checkCloseConnection>
        </quickHttpRequest>
        <outputLocalFileSize>26</outputLocalFileSize>
        <numOutputBytesWritten>26</numOutputBytesWritten>
      </httpDownloadFile>
    </a_httpDownload>
    <totalElapsedMs>47</totalElapsedMs>
    <ContentLength>0</ContentLength>
    <info>Success.</info>
  </Download>
</ChilkatLog>

А вот ответ об ошибке / сбое (для почтового запроса):

<ChilkatLog>
  <SynchronousRequest>
    <DllDate>Dec 21 2018</DllDate>
    <ChilkatVersion>9.5.0.76</ChilkatVersion>
    <Architecture>Little Endian; 32-bit</Architecture>
    <Language>.NET 4.0</Language>
    <VerboseLogging>0</VerboseLogging>
    <domain>191.168.1.101</domain>
    <port>8000</port>
    <ssl>0</ssl>
    <httpRequest>
      <httpVersion>1.1</httpVersion>
      <verb>POST</verb>
      <path>/fileAdmin.php</path>
      <contentType>multipart/form-data</contentType>
      <charset>windows-1252</charset>
      <sendCharset>0</sendCharset>
      <mimeHeader></mimeHeader>
      <requestParams>
        <requestItem>
          <name>fileAction</name>
          <value>Upload</value>
        </requestItem>
        <requestItem>
          <name>fileName</name>
          <value>DB.sql</value>
        </requestItem>
        <requestItem>
          <name>adminFile</name>
          <fileOnDisk>G:\c.dll</fileOnDisk>
          <numValueBytes>8697</numValueBytes>
        </requestItem>
      </requestParams>
    </httpRequest>
    <fullRequest>
      <a_synchronousRequest>
        <generateRequestHeader>
          <httpRequestGenStartLine>
            <genStartLine>
              <startLine>POST /fileAdmin.php HTTP/1.1</startLine>
            </genStartLine>
          </httpRequestGenStartLine>
          <addCookies>
            <info>Not auto-adding cookies.</info>
            <sendCookies>1</sendCookies>
            <cookieDir></cookieDir>
          </addCookies>
          <genMultipartFormData>
            <requestParam>
              <name>fileAction</name>
            </requestParam>
            <requestParam>
              <name>fileName</name>
            </requestParam>
            <requestParam>
              <name>adminFile</name>
              <filename>G:\c.dll</filename>
            </requestParam>
          </genMultipartFormData>
        </generateRequestHeader>
        <fullHttpRequest>
          <domain>191.168.1.101</domain>
          <port>8000</port>
          <ssl>0</ssl>
          <openHttpConnection>
            <info>Opening connection directly to HTTP server.</info>
            <httpHostname>191.168.1.101</httpHostname>
            <httpPort>8000</httpPort>
            <tls>False</tls>
            <socket2Connect>
              <connect2>
                <connectSocket>
                  <connect_ipv6_or_ipv4>
                    <info>Connection attempt failed.</info>
                    <maxWaitTimeMs>10000</maxWaitTimeMs>
                    <totalMsWaitedSoFar>2100</totalMsWaitedSoFar>
                  </connect_ipv6_or_ipv4>
                  <connect_ipv6_or_ipv4>
                    <info>Connection attempt failed.</info>
                    <maxWaitTimeMs>10000</maxWaitTimeMs>
                    <totalMsWaitedSoFar>2150</totalMsWaitedSoFar>
                  </connect_ipv6_or_ipv4>
                </connectSocket>
                <ConnectFailReason>Connection rejected</ConnectFailReason>
                <error>A few possible causes for a connection being rejected are:</error>
                <error>- A firewall (software or hardware), such as Windows Firewall, is blocking the connection .</error>
                <error>- Nothing is listening at the remote host:port</error>
              </connect2>
            </socket2Connect>
          </openHttpConnection>
        </fullHttpRequest>
        <success>0</success>
      </a_synchronousRequest>
      <success>0</success>
    </fullRequest>
    <totalTime>Elapsed time: 4390 millisec</totalTime>
    <error>Failed.</error>
  </SynchronousRequest>
</ChilkatLog>

Может кто-нибудь сказать мне, что может быть причиной этого?

заранее спасибо

С наилучшими пожеланиями

1 Ответ

0 голосов
/ 17 апреля 2019

Возможные причины присутствуют в LastErrorText:

            <ConnectFailReason>Connection rejected</ConnectFailReason>
            <error>A few possible causes for a connection being rejected are:</error>
            <error>- A firewall (software or hardware), such as Windows Firewall, is blocking the connection .</error>
            <error>- Nothing is listening at the remote host:port</error>

Я предполагаю, что брандмауэр Windows блокирует исходящий POST.

В этом примере показаны ошибки, которые могут возникнуть при различных проблемах подключения к сокету TCP: https://www.example -code.com / vbnet / socket_connect_fail.asp

...