Я уже настроил настройки на клиенте и сервере, но проблема продолжается. Мне нужны инструкции о том, что может быть причиной этой проблемы и как ее устранить.
Клиент C#
Код: Выделить всё
private async Task SendRequest(string xmlKey, string diretorioPdf, string contentXml)
{
client.DefaultRequestHeaders.Add("xmlKey", xmlKey);
client.DefaultRequestHeaders.Add("diretorioPdf", diretorioPdf);
var content = new StringContent($"{{\"content\":\"{Convert.ToBase64String(Encoding.UTF8.GetBytes(contentXml))}\"}}", Encoding.UTF8, "application/json");
var response = await client.PostAsync("http://localhost:3000/conversao.php", content);
response.EnsureSuccessStatusCode();
}
Сервер декодирует содержимое Base64 и обрабатывает XML. Он проверяет необходимые заголовки и генерирует PDF-файл.
Код: Выделить всё
$headers = getallheaders();
if (!isset($headers['xmlKey']) || !isset($headers['diretorioPdf'])) {
header('Content-Type: application/json');
echo json_encode(["status" => "Missing headers"]);
exit();
}
$jsonData = file_get_contents('php://input');
$data = json_decode($jsonData, true);
if (!isset($data['content'])) {
echo "Missing 'content' field.";
exit();
}
$xml = base64_decode($data['content']);
// Processes the XML and generates the PDF...
Снизил порог конкуренции в клиенте C#
Код: Выделить всё
private readonly SemaphoreSlim semaphore = new SemaphoreSlim(10); // Maxde 10 threads
После запуска первые 78 файлов XML преобразуются, а затем возникает эта ошибка:
Код: Выделить всё
The response status code does not indicate success: 400 (Bad Request).
in System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
in Cocal.Src.Xml.TransformarEmPDF.ConversorPDF.d__19.MoveNext() in C:\Users\sserg\source\repos\Cocal\Cocal\Src\Xml\TransformarEmPDF\ConversorPDF.cs:linha 155
--- End stack trace of the previous location where the exception was thrown ---
in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
in System.Runtime.CompilerServices.TaskAwaiter.GetResult()
in Cocal.Src.Xml.TransformarEmPDF.ConversorPDF.
d__18.MoveNext() in C:\Users\sserg\source\repos\Cocal\Cocal\Src\Xml\TransformarEmPDF\ConversorPDF.cs:linha 123
in System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
in Cocal.Src.Xml.TransformarEmPDF.ConversorPDF.d__19.MoveNext() na C:\Users\sserg\source\repos\Cocal\Coc
Ошибка в (C:\xampp\apache\logs\error.log)
Код: Выделить всё
[Mon Dec 09 16:52:23.643126 2024] [ssl:warn] [pid 10384:tid 612] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Mon Dec 09 16:52:23.769786 2024] [core:warn] [pid 10384:tid 612] AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Mon Dec 09 16:52:23.773776 2024] [ssl:warn] [pid 10384:tid 612] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Mon Dec 09 16:52:24.651449 2024] [mpm_winnt:notice] [pid 10384:tid 612] AH00455: Apache/2.4.58 (Win64) OpenSSL/3.1.3 PHP/8.2.12 configured -- resuming normal operations
[Mon Dec 09 16:52:24.651449 2024] [mpm_winnt:notice] [pid 10384:tid 612] AH00456: Apache Lounge VS17 Server built: Oct 18 2023 13:03:18
[Mon Dec 09 16:52:24.651449 2024] [core:notice] [pid 10384:tid 612] AH00094: Command line: 'c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Mon Dec 09 16:52:24.657432 2024] [mpm_winnt:notice] [pid 10384:tid 612] AH00418: Parent: Created child process 33444
[Mon Dec 09 16:52:25.432362 2024] [ssl:warn] [pid 33444:tid 632] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Mon Dec 09 16:52:25.534090 2024] [ssl:warn] [pid 33444:tid 632] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Mon Dec 09 16:52:25.646789 2024] [mpm_winnt:notice] [pid 33444:tid 632] AH00354: Child: Starting 150 worker threads.
[Wed Dec 11 23:26:10.601035 2024] [ssl:warn] [pid 26360:tid 600] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Wed Dec 11 23:26:10.688648 2024] [core:warn] [pid 26360:tid 600] AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Wed Dec 11 23:26:10.693636 2024] [ssl:warn] [pid 26360:tid 600] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Wed Dec 11 23:26:11.366501 2024] [mpm_winnt:notice] [pid 26360:tid 600] AH00455: Apache/2.4.58 (Win64) OpenSSL/3.1.3 PHP/8.2.12 configured -- resuming normal operations
[Wed Dec 11 23:26:11.366501 2024] [mpm_winnt:notice] [pid 26360:tid 600] AH00456: Apache Lounge VS17 Server built: Oct 18 2023 13:03:18
[Wed Dec 11 23:26:11.366501 2024] [core:notice] [pid 26360:tid 600] AH00094: Command line: 'c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Wed Dec 11 23:26:11.371489 2024] [mpm_winnt:notice] [pid 26360:tid 600] AH00418: Parent: Created child process 26504
[Wed Dec 11 23:26:12.029726 2024] [ssl:warn] [pid 26504:tid 604] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Wed Dec 11 23:26:12.109550 2024] [ssl:warn] [pid 26504:tid 604] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Wed Dec 11 23:26:12.173341 2024] [mpm_winnt:notice] [pid 26504:tid 604] AH00354: Child: Starting 150 worker threads.
PHP 8.2.12 (cli) (создан: 24 октября 2023 г., 21:15:15) (ZTS Visual C++ 2019 x64)
Авторское право (c) The PHP Group
Zend Engine v4.2.12, Авторское право (c) Zend Technologies
Даже при всем этом XML-файлы были преобразованы из 78 файлов в 78 файлов, а затем возникла ошибка.
Можете ли вы помочь мне понять, что происходит? Я не смог решить эту проблему с помощью генеративного ИИ.
Подробнее здесь: https://stackoverflow.com/questions/792 ... nd-c-sharp