2016-08-02 10 views
0

私のデスクトップアプリケーションは、Apacheサーバ(HTTPスクリプトとやりとりする)にHTTPでデータを投稿しています。私はたくさんのデータ(サイズが800kbのファイルの内容)を投稿しています。HTTP大規模な文字列を送信するとリクエストタイムアウトになる

私は、HTTP POSTリクエストを送信すると、タイムアウトするWindowsエラー以下と:

ERROR_INTERNET_TIMEOUT The request has timed out

しかし、私は小さなファイルを送信するならば、すべてがうまくあり、私のPHPスクリプトはPOSTリクエストを処理します。これの原因は何か、そしてこれをどのように修正することができますか?

私のウェブサイトはWordPressで、私はphp.iniphp5.ini.user.iniをすべて変更しましたが、それでも大きなファイルでは失敗します。

file_uploads = On 
post_max_size = 128M 
upload_max_filesize = 128M 

編集phpinfo();を使用して検査した後(max_execution_timeには秒間(最後のSを持っている必要があります):?

  • max_execution_timeは10
  • のmemory_limit 128M
  • post_max_sizeの128M
  • upload_max_filesize 128M
  • max_input_nesting_level 64
  • max_input_time 10
  • max_input_vars 1000年

C++コード:

TCHAR hdrs[] = _T("Content-Type: application/x-www-form-urlencoded"); 
LPSTR accept[2] = { "*/*", NULL }; 

HINTERNET hConnect = NULL, hSession = NULL, hRequest = NULL; 
DWORD len = postData.length() * 2; 
tstring formattedPostData(len, ' '); 
InternetCanonicalizeUrl(postData.c_str(), &formattedPostData[0], &len, ICU_BROWSER_MODE); 
std::replace(formattedPostData.begin(), formattedPostData.end(), '=', '~'); 
tstring authData = _T("usage=") + formattedPostData + _T("&auth=") + authToken; 

hSession = InternetOpen(_T("uploader"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); 
if (!hSession) { 
    output(_T("InternetOpen failed: %s\n"), getLastErrorAsString().c_str()); 
    res = S_UNDEFINED_ERROR.state; 
    goto Cleanup; 
} 

hConnect = InternetConnect(hSession, domain.c_str(), 
    INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1); 
if (!hConnect) { 
    output(_T("InternetConnect failed: %s\n"), getLastErrorAsString().c_str()); 
    res = S_UNDEFINED_ERROR.state; 
    goto Cleanup; 
} 

hRequest = HttpOpenRequest(hConnect, _T("POST"), 
    domainScript.c_str(), NULL, NULL, (LPCWSTR*)&accept, INTERNET_FLAG_NO_CACHE_WRITE, 1); 
if (!hRequest) { 
    output(_T("HttpOpenRequest failed: %s\n"), getLastErrorAsString().c_str()); 
    res = S_UNDEFINED_ERROR.state; 
    goto Cleanup; 
} 

// Error occurs here 
output(_T("Post: %s\n"), authData.c_str()); 
if (!HttpSendRequest(hRequest, hdrs, -1, (LPVOID)authData.c_str(), authData.size() * sizeof(TCHAR))) { 
    // Error is 12002: timeout 
    output(_T("HttpSendRequest failed: %d.\n"), GetLastError()); 
    res = S_UNDEFINED_ERROR.state; 

    char responseText[1024]; 
    DWORD responseTextSize = sizeof(responseText); 

    output(_T("Res: %d\n"), HttpQueryInfo(hRequest, HTTP_QUERY_RAW_HEADERS_CRLF, &responseText, &responseTextSize, NULL)); 
    output(_T("Response: %s\n"), responseText); 

    goto Cleanup; 
} 
+0

エラーログを確認してお知らせください。 –

+0

これはあなたを助けるかもしれません:[max_input_time](http://php.net/manual/de/info.configuration.php#ini.max-input-time) –

+0

@SachinG。エラーログを確認しましたが、今日はエントリがありません。 – Merl

答えて

1

は、スクリプトのタイムアウトが増加したことがありますか?

http://php.net/manual/en/function.set-time-limit.php

はまた、あなたがテキストエリアなどにcopy'n'pastedファイルやテキストのチャンクを投稿していますか?

+0

私のデスクトップアプリケーションは、1つの長い文字列としてファイルの内容を投稿しています。たとえば、 'fileContents = abc ....&auth = abc' – Merl

+0

httpの投稿として、または入手できますか?送信している文字列にもそこに奇妙な文字がありますか? –

+0

その投稿とそれはurlencodedですが、私はポスト書式 – Merl

関連する問題