Enviar archivo desde Curl PHP a servidor MVC y recuperarlo por request

Tengo una pagina con PHP en la que añado un archivo, y tengo que mandarlo, junto con más información a un servicio web en c#.

Mi código actual es

$ datosEnvio = array(DATOS);

$ urlEnvio = ‘URL AL SERVICIO WEB’;

$ contentEnvio = json_encode($ datosEnvio);

$ curlEnvio = curl_init($ urlEnvio);

curl_setopt($ curlEnvio, CURLOPT_HEADER, false);

curl_setopt($ curlEnvio, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ curlEnvio, CURLOPT_HTTPHEADER, array(“Content-type: application/json”));

curl_setopt($ curlEnvio, CURLOPT_POST, true);

curl_setopt($ curlEnvio, CURLOPT_POSTFIELDS, $ contentEnvio);

$ json_responseEnvio = curl_exec($ curlEnvio);

$ statusEnvio = curl_getinfo($ curlEnvio, CURLINFO_HTTP_CODE);

curl_close($ curlEnvio);

Esto se ejecuta en el submit de la pagina, ¿que tengo que modificar para que al servicio web me llegue un archivo que tengo en memoria? A ser posible para recuperarlo por request.

Cómo leer o recorer los nodos de un XML que se recibe por curl

este es l planteamiento: Recibo una respuesta XML desde un curl en PHP, pretendo obtener ciertos nodos. Este es un trozo del código que interesa:

$  response = curl_exec($  ch);     $  dataXml    = simplexml_load_string($  response); $  dataXml->registerXPathNamespace('soap', 'http://schemas.xmlsoap.org/soap/envelope/'); //$  xxx=$  dataXml->xpath('//soap:Respuestas->DatosIdiomas->DatosEnvios->Datos->Fecha'); $  xxx=$  dataXml->xpath('//soap:Respuestas'); echo "xxx ".$  xxx; 

Quiero contar cuantos nodos son, en este caso de los nodos: “Estado” y “Fecha”.

La respuesta que estoy recibiendo del curl es esta:

<?xml version="1.0" encoding="Windows-1252"?><ConsultaXMLout xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><Respuestas><DatosIdiomas><DatosEnvios><Datos Idioma="1" Codigo="PQ5KF90200060650103203Q" Evento="1" web_id="Sin web_id"><Estado>Pre registro</Estado><Fecha>29/05/2019</Fecha></Datos><Datos Idioma="1" Codigo="PQ5KF90200060650103203Q" Evento="2"><Estado>Admitido</Estado><Fecha>29/05/2019</Fecha></Datos><Datos Idioma="1" Codigo="PQ5KF90200060650103203Q" Evento="3"><Estado>Intento de entrega</Estado><Fecha>30/05/2019</Fecha></Datos><Datos Idioma="1" Codigo="PQ5KF90200060650103203Q" Evento="4"><Estado>Intento de entrega</Estado><Fecha>30/05/2019</Fecha></Datos><Datos Idioma="1" Codigo="PQ5KF90200060650103203Q" Evento="5"><Estado>Intento de entrega</Estado><Fecha>30/05/2019</Fecha></Datos><Datos Idioma="1" Codigo="PQ5KF90200060650103203Q" Evento="6"><Estado>Intento de entrega</Estado><Fecha>30/05/2019</Fecha></Datos><Datos Idioma="1" Codigo="PQ5KF90200060650103203Q" Evento="7"><Estado>Entregado.</Estado><Fecha>30/05/2019</Fecha></Datos></DatosEnvios></DatosIdiomas></Respuestas></ConsultaXMLout> xxx Array 

Curl возвращает window.location = “http://”;

При отправке формы на сайте, перехватываю событие, собираю данные и отправляю их по API в другой сервис. Для запроса использую curl. При дампе ответа получаю

<script>   window.location = "http://"; </script>

Хотя данные и ушли и все с ними отлично. Как будто он два засылает запрос , второй раз не имея данных. Вот метод который выполняет запрос:

private function sendQuery($  url, $  data)     {         $  resData = http_build_query($  data, '', '&');         $  resUrl = $  this->urlRW . $  url;             if ($  curl = curl_init() ) {                 curl_setopt($  curl, CURLOPT_URL, $  resUrl );                 curl_setopt($  curl, CURLOPT_RETURNTRANSFER, true);                 curl_setopt($  curl, CURLOPT_POST, true);                 curl_setopt($  curl, CURLOPT_POSTFIELDS, $  resData);                 $  response = curl_exec($  curl);                 curl_close($  curl);                                 try {                     $  response = json_decode($  response);                     $  this->responseQuery = $  response                 } catch (Exception $  e) {                     $  this->responseQuery = "Error parse response";            }         }     }

how to fix curl removing other dependencies?

I wanted to install node js on Ubuntu 18.04. I did from the official repository.

sudo apt install nodejs npm. 

Then found the version is 8. So I wanted to update it following the official doc.

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - sudo apt-get install -y nodejs 

It said curl is not installed. So I installed curl. sudo apt install curl.

And I got this message.

dpkg: libcurl3:amd64: dependency problems, but removing anyway as you requested:  opera-stable depends on libcurl3 (>= 7.16.2) | libcurl4 (>= 7.58.0); however:   Package libcurl3:amd64 is to be removed.   Package libcurl4 is not installed.  atom depends on libcurl3 | libcurl4; however:   Package libcurl3:amd64 is to be removed.   Package libcurl4 is not installed.  Removing libcurl3:amd64 (7.58.0-2ubuntu2) ... Selecting previously unselected package libcurl4:amd64. (Reading database ... 305616 files and directories currently installed.) 

How to fix it now?

How do I decode curl url encoded string in a C++ server

I am using the c++ pastiche rest api library to make a rest api in ubuntu linux. I have got the server to work without problems. I can use php curl to post data to my server. The server receives the data and can return the data. The problem is this. When I post to the server with curl post it sends it to the server in a url encoded string like this name=percy&age=34&eye_color=blue. I need to know how to in C++ put each one into a string. Also one of the fields may also have binary data as well as ordinary strings. I have already written the code to interpret the binary data, but I don’t know how to convert the string from curl post at the moment. Please ignore the fact my port is different in my php. The reason is that I am running ubuntu in virtualbox.

I need to extract strings and binary data from the post I am sending. This is what I don’t know how to do. I am not sure if I may need another library to do this, or not

Here is my php code:-

$  postData = http_build_query(             array(                 'dstdata' => 'hello',                 'more' => 'test',                 'age' => 34             )         ); $  ch = curl_init(); curl_setopt($  ch, CURLOPT_URL, 'localhost:9999/about');         curl_setopt($  ch, CURLOPT_CUSTOMREQUEST, "POST");         curl_setopt($  ch, CURLOPT_POSTFIELDS, $  postData);         curl_setopt($  ch, CURLOPT_RETURNTRANSFER, true);         $  output = curl_exec($  ch);         print_r($  output);                curl_close($  ch); 

The above code would make a string like this dstdata=hello&more=test&age=34

And here the c++ server code. You can see I have two routes setup here:-

#include <pistache/router.h> #include "pistache/endpoint.h" #include "pistache/http.h" #include <iostream>  using namespace Pistache; using namespace Rest;  Rest::Router router;  void sausage(const Rest::Request& request, Http::ResponseWriter response){     std::cout << "We have contact" << std::endl;     response.send(Http::Code::Ok, "Bottoms Up\n"); }  void about(const Rest::Request& request, Http::ResponseWriter response){     std::cout << "Server Running" << std::endl;     response.send(Http::Code::Ok, request.body()); }  int main(){     Routes::Get(router,"/ready",Routes::bind(&sausage));     Routes::Post(router,"/about",Routes::bind(&about));     Pistache::Address addr(Pistache::Ipv4::any(), Pistache::Port(9080));     auto opts = Pistache::Http::Endpoint::options()         .threads(10).flags(         Pistache::Tcp::Options::ReuseAddr);     Http::Endpoint server(addr);     server.init(opts);     server.setHandler(router.handler());     server.serve();     return 0; }    

Requisição via post usando curl php

Tenho que fazer uma requisição para um api. Está é a requisição:

<?php  $  url = 'http://api.credgestao.com.br/JsonService.aspx';  $  stringJson = array(     "CodigoProduto" => '86',     "Versao" => '20180521',     "ChaveAcesso" => "exemplo",     "Parametros" => array(         "TipoPessoa" => 'J',         "CPFCNPJ" => '77973317000139',         "UF" => 'SP'     ) );  function sendJsonOverPost($  url, $  stringJson) {     $  ch = curl_init();     curl_setopt($  ch, CURLOPT_URL, $  url);      // For xml, change the content-type.     curl_setopt ($  ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/json"));      curl_setopt($  ch, CURLOPT_POST, 1);     curl_setopt($  ch, CURLOPT_POSTFIELDS, $  stringJson);      curl_setopt($  ch, CURLOPT_RETURNTRANSFER, 1); // ask for results to be returned      // Send to remote and return data to caller.     $  response = curl_exec($  ch);     curl_close($  ch);     return $  response; [![}][1]][1] 

$ response = sendJsonOverPost($ url, json_encode($ stringJson));
echo $ response; ?>

Esse é json que a api requer que eu passe: Porém dá o seguinte retorno: inserir a descrição da imagem aqui

Sporadic SSL_read errors when uploading large files through mod/jk with curl

I have a nightly backup script that has been working reliably for 6 years, and two months ago, it began to fail to upload to my archive server (only about 1 in 4 attempts succeed). This started to happen once the size of the backup file surpassed about 440MB (successful uploads take 20-40 seconds to complete). Other, smaller files (>200MB) are uploading successfully every time.

Here are the details of the file I am uploading:

-rw-r--r-- 1 backup backup 486948951 Jun 12 13:20 snapshot-20190612.zip 

These files are uploaded to my server with a curl PUT (see command below). The source server is an Amazon Linux instance in Virginia, and the destination server is an Amazon Linux instance in the Ohio (both are in the US East region).

The web service that handles the upload is an Apache HTTPD 2.4.39 + mod24_ssl/OpenSSL 1.0.2k -> mod_jk 1.2.42 -> Apache Tomcat 8.5.40 -> Artifactory 5.3.2 instance.


My mod/jk workers.properties file:

worker.list=main_ajp13_worker # Set properties for main_ajp13_worker (ajp13) worker.main_ajp13_worker.type=ajp13 worker.main_ajp13_worker.host=localhost worker.main_ajp13_worker.port=8009 

The following are the console output (authorization details scrubbed) from a failed upload, followed immediately by a successful upload:

-bash-4.2$   curl -v -k -u backup:PASSWORD -H X-Checksum-Sha1:6b9525bf9bb572ec7f70d0d474cb6533e0091bd3 -H X-Checksum-Md5:6da0c444ad1b53dc1cf06784e204cb10 -T snapshot-20190612.zip https://repo.mydomain.org/resource-snapshot/snapshot/20190612/snapshot-20190612.zip *   Trying 123.222.100.132... * TCP_NODELAY set * Connected to repo.mydomain.org (123.222.100.132) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH * successfully set certificate verify locations: *   CAfile: /etc/pki/tls/certs/ca-bundle.crt   CApath: none * TLSv1.2 (OUT), TLS header, Certificate Status (22): * TLSv1.2 (OUT), TLS handshake, Client hello (1): * TLSv1.2 (IN), TLS handshake, Server hello (2): * TLSv1.2 (IN), TLS handshake, Certificate (11): * TLSv1.2 (IN), TLS handshake, Server key exchange (12): * TLSv1.2 (IN), TLS handshake, Server finished (14): * TLSv1.2 (OUT), TLS handshake, Client key exchange (16): * TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1): * TLSv1.2 (OUT), TLS handshake, Finished (20): * TLSv1.2 (IN), TLS change cipher, Change cipher spec (1): * TLSv1.2 (IN), TLS handshake, Finished (20): * SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256 * ALPN, server accepted to use http/1.1 * Server certificate: *  subject: OU=Domain Control Validated; OU=PositiveSSL Wildcard; CN=*.mydomain.org *  start date: May 28 00:00:00 2019 GMT *  expire date: May 27 23:59:59 2021 GMT *  issuer: C=GB; ST=Greater Manchester; L=Salford; O=Sectigo Limited; CN=Sectigo RSA Domain Validation Secure Server CA *  SSL certificate verify ok. * Server auth using Basic with user 'backup' > PUT /resource-snapshot/snapshot/20190612/snapshot-20190612.zip HTTP/1.1 > Host: repo.mydomain.org > Authorization: Basic DELETED_TOKEN > User-Agent: curl/7.61.1 > Accept: */* > X-Checksum-Sha1:6b9525bf9bb572ec7f70d0d474cb6533e0091bd3 > X-Checksum-Md5:6da0c444ad1b53dc1cf06784e204cb10 > Content-Length: 486948951 > Expect: 100-continue > < HTTP/1.1 100 Continue * OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 104 * Closing connection 0 curl: (56) OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 104  -bash-4.2$   curl -v -u backup:PASSWORD -H X-Checksum-Sha1:6b9525bf9bb572ec7f70d0d474cb6533e0091bd3 -H X-Checksum-Md5:6da0c444ad1b53dc1cf06784e204cb10 -T snapshot-20190612.zip https://repo.mydomain.org/resource-snapshot/snapshot/20190612/snapshot-20190612.zip *   Trying 123.222.100.132... * TCP_NODELAY set * Connected to repo.mydomain.org (123.222.100.132) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH * successfully set certificate verify locations: *   CAfile: /etc/pki/tls/certs/ca-bundle.crt   CApath: none * TLSv1.2 (OUT), TLS header, Certificate Status (22): * TLSv1.2 (OUT), TLS handshake, Client hello (1): * TLSv1.2 (IN), TLS handshake, Server hello (2): * TLSv1.2 (IN), TLS handshake, Certificate (11): * TLSv1.2 (IN), TLS handshake, Server key exchange (12): * TLSv1.2 (IN), TLS handshake, Server finished (14): * TLSv1.2 (OUT), TLS handshake, Client key exchange (16): * TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1): * TLSv1.2 (OUT), TLS handshake, Finished (20): * TLSv1.2 (IN), TLS change cipher, Change cipher spec (1): * TLSv1.2 (IN), TLS handshake, Finished (20): * SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256 * ALPN, server accepted to use http/1.1 * Server certificate: *  subject: OU=Domain Control Validated; OU=PositiveSSL Wildcard; CN=*.mydomain.org *  start date: May 28 00:00:00 2019 GMT *  expire date: May 27 23:59:59 2021 GMT *  issuer: C=GB; ST=Greater Manchester; L=Salford; O=Sectigo Limited; CN=Sectigo RSA Domain Validation Secure Server CA *  SSL certificate verify ok. * Server auth using Basic with user 'backup' > PUT /resource-snapshot/snapshot/20190612/snapshot-20190612.zip HTTP/1.1 > Host: repo.mydomain.org > Authorization: Basic DELETED_TOKEN > User-Agent: curl/7.61.1 > Accept: */* > X-Checksum-Sha1:6b9525bf9bb572ec7f70d0d474cb6533e0091bd3 > X-Checksum-Md5:6da0c444ad1b53dc1cf06784e204cb10 > Content-Length: 486948951 > Expect: 100-continue > < HTTP/1.1 100 Continue * OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 104 * Closing connection 0 curl: (56) OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 104 

With a second (or often third or fourth) attempt of the upload, it eventually succeeds:

-bash-4.2$   curl -v -u backup:PASSWORD -H X-Checksum-Sha1:6b9525bf9bb572ec7f70d0d474cb6533e0091bd3 -H X-Checksum-Md5:6da0c444ad1b53dc1cf06784e204cb10 -T snapshot-20190612.zip https://repo.mydomain.org/resource-snapshot/snapshot/20190612/snapshot-20190612.zip *   Trying 123.222.100.132... * TCP_NODELAY set * Connected to repo.mydomain.org (123.222.100.132) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH * successfully set certificate verify locations: *   CAfile: /etc/pki/tls/certs/ca-bundle.crt   CApath: none * TLSv1.2 (OUT), TLS header, Certificate Status (22): * TLSv1.2 (OUT), TLS handshake, Client hello (1): * TLSv1.2 (IN), TLS handshake, Server hello (2): * TLSv1.2 (IN), TLS handshake, Certificate (11): * TLSv1.2 (IN), TLS handshake, Server key exchange (12): * TLSv1.2 (IN), TLS handshake, Server finished (14): * TLSv1.2 (OUT), TLS handshake, Client key exchange (16): * TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1): * TLSv1.2 (OUT), TLS handshake, Finished (20): * TLSv1.2 (IN), TLS change cipher, Change cipher spec (1): * TLSv1.2 (IN), TLS handshake, Finished (20): * SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256 * ALPN, server accepted to use http/1.1 * Server certificate: *  subject: OU=Domain Control Validated; OU=PositiveSSL Wildcard; CN=*.mydomain.org *  start date: May 28 00:00:00 2019 GMT *  expire date: May 27 23:59:59 2021 GMT *  issuer: C=GB; ST=Greater Manchester; L=Salford; O=Sectigo Limited; CN=Sectigo RSA Domain Validation Secure Server CA *  SSL certificate verify ok. * Server auth using Basic with user 'backup' > PUT /resource-snapshot/snapshot/20190612/snapshot-20190612.zip HTTP/1.1 > Host: repo.mydomain.org > Authorization: Basic DELETED_TOKEN > User-Agent: curl/7.61.1 > Accept: */* > X-Checksum-Sha1:6b9525bf9bb572ec7f70d0d474cb6533e0091bd3 > X-Checksum-Md5:6da0c444ad1b53dc1cf06784e204cb10 > Content-Length: 486948951 > Expect: 100-continue > < HTTP/1.1 100 Continue * We are completely uploaded and fine < HTTP/1.1 201 201 < Date: Wed, 12 Jun 2019 13:22:46 GMT < Server: Apache < Strict-Transport-Security: max-age=15768000 < X-Artifactory-Id: 9e49bf90cd4b7700:7ba45cf1:16b1db56e4d:-8000 < Location: https://repo.mydomain.org/resource-snapshot/snapshot/20190612/snapshot-20190612.zip < Transfer-Encoding: chunked < Content-Type: application/vnd.org.jfrog.artifactory.storage.itemcreated+json;charset=ISO-8859-1 < {   "repo" : "resource-snapshot",   "path" : "/snapshot/20190612/snapshot-20190612.zip",   "created" : "2019-06-12T13:23:05.805Z",   "createdBy" : "backup",   "downloadUri" : "https://repo.mydomain.org/resource-snapshot/snapshot/20190612/snapshot-20190612.zip",   "mimeType" : "application/zip",   "size" : "486948951",   "checksums" : {     "sha1" : "6b9525bf9bb572ec7f70d0d474cb6533e0091bd3",     "md5" : "6da0c444ad1b53dc1cf06784e204cb10"   },   "originalChecksums" : {     "sha1" : "6b9525bf9bb572ec7f70d0d474cb6533e0091bd3",     "md5" : "6da0c444ad1b53dc1cf06784e204cb10"   },   "uri" : "https://repo.mydomain.org/resource-snapshot/snapshot/20190612/snapshot-20190612.zip" * Connection #0 to host repo.mydomain.org left intact } 

The server logs aren’t particularly informative. Here are the relevant logs when an upload fails:

/var/log/httpd/ssl_request_log

[24/Jun/2019:12:17:45 +0000] 52.1.100.190 TLSv1.2 ECDHE-RSA-AES128-GCM-SHA256 "PUT /resource-snapshot/snapshot/20190612/snapshot-20190612.zip HTTP/1.1" - 

/var/log/httpd/repo.mydomain.org-ssl_access_log

140.1.100.101 - - [24/Jun/2019:12:17:45 +0000] "PUT /resource-snapshot/snapshot/20190612/snapshot-20190612.zip HTTP/1.1" 400 - 

catalina.out

No log entries.

/var/log/httpd/mod_jk.log

These are the logs when the mod/jk log level is set to info:

[Mon Jun 24 12:18:05 2019] [15679:140534117611584] [info] ajp_read_into_msg_buff::jk_ajp_common.c (1553): (main_ajp13_worker) receiving data from client failed. Connection aborted or network problems [Mon Jun 24 12:18:05 2019] [15679:140534117611584] [info] ajp_process_callback::jk_ajp_common.c (2105): (main_ajp13_worker) Reading from client aborted or client network problems [Mon Jun 24 12:18:05 2019] [15679:140534117611584] [info] ajp_service::jk_ajp_common.c (2778): (main_ajp13_worker) sending request to tomcat failed (unrecoverable), because of client read error (attempt=1) [Mon Jun 24 12:18:05 2019] [15679:140534117611584] [info] jk_handler::mod_jk.c (2988): Aborting connection for worker=main_ajp13_worker 

And here is the relevant part of the 2.4 million mod_jk log entries at the debug level, starting right at the HTTP 100 Continue and showing the very start of the file upload (you can see the magic number of the zip file, 50 4B 03 04):

[Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1267): 0160    32 65 32 00 A0 08 00 09 34 39 36 32 37 38 36 30  - 2e2.....49627860 [Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1267): 0170    33 00 00 06 45 78 70 65 63 74 00 00 0C 31 30 30  - 3...Expect...100 [Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1267): 0180    2D 63 6F 6E 74 69 6E 75 65 00 0A 00 0F 41 4A 50  - -continue....AJP [Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1267): 0190    5F 52 45 4D 4F 54 45 5F 50 4F 52 54 00 00 05 33  - _REMOTE_PORT...3 [Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1267): 01a0    32 39 37 30 00 0A 00 0E 41 4A 50 5F 4C 4F 43 41  - 2970....AJP_LOCA [Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1267): 01b0    4C 5F 41 44 44 52 00 00 0C 31 37 32 2E 33 31 2E  - L_ADDR...172.31. [Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1267): 01c0    31 33 2E 39 36 00 0A 00 10 4A 4B 5F 4C 42 5F 41  - 13.96....JK_LB_A [Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1267): 01d0    43 54 49 56 41 54 49 4F 4E 00 00 03 41 43 54 00  - CTIVATION...ACT. [Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1267): 01e0    0A 00 0F 53 53 4C 5F 43 4C 49 45 4E 54 5F 43 45  - ...SSL_CLIENT_CE [Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1267): 01f0    52 54 00 00 0F 53 53 4C 5F 43 4C 49 45 4E 54 5F  - RT...SSL_CLIENT_ [Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1267): 0200    43 45 52 54 00 FF 00 00 00 00 00 00 00 00 00 00  - CERT............ [Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_send_request::jk_ajp_common.c (1782): (main_ajp13_worker) request body to send 496278603 - request body to resend 0 [Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_send_request::jk_ajp_common.c (1886): (main_ajp13_worker) sending 8186 bytes of request body [Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1267): sending to ajp13 pos=4 len=8192 max=8192 [Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1267): 0000    12 34 1F FC 1F FA 50 4B 03 04 14 00 00 00 08 00  - .4....PK........ [Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1267): 0010    84 61 D8 4E 73 67 93 AF 7C 0A 00 00 E0 B0 00 00  - .a.Nsg..|....... [Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1267): 0020    0A 00 1C 00 62 61 63 6B 75 70 2E 6C 6F 67 55 54  - ....backup.logUT [Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1267): 0030    09 00 03 18 BE 10 5D 90 BD 10 5D 75 78 0B 00 01  - ......]...]ux... [Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1267): 0040    04 1A 00 00 00 04 1A 00 00 00 ED 5C 4D 6F DC C8  - ...........\Mo.. [Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1267): 0050    11 BD E7 57 34 74 4A 80 D8 80 77 17 8B 45 80 1C  - ...W4tJ...w..E..  .... [lots of encoded data trimmed out here, the next part shows re-filling the 8k buffer] ....  [Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_connection_tcp_get_message::jk_ajp_common.c (1462): received from ajp13 pos=0 len=3 max=8192E D7 E9 E6 DD BB  - 8...U?.er.>..... [Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_connection_tcp_get_message::jk_ajp_common.c (1462): 00000   06 1F FA 00 00 00 00 00 00 00 00 00 00 00 00 00  - ................. [Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1267): sending to ajp13 pos=4 len=8192 max=8192 2E 40 41 4C 94  - ..$  z~YW.?1G.@AL. [Mon Jun 24 14:37:08 2019] [17826:139891516274752] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1267): 0000    12 34 1F FC 1F FA C9 62 3E 48 C5 70 E9 05 E1 8D  - .4.....b>H.p....  .... [lots of encoded data trimmed out here, the next part shows where re-filling the 8k buffer fails] ....  [Mon Jun 24 14:37:28 2019] [17826:139891516274752] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1267): 03e0    2D E5 36 F3 8C 12 8C 51 69 66 21 AE A5 58 BE 6E  - -.6....Qif!..X.n [Mon Jun 24 14:37:28 2019] [17826:139891516274752] [debug] ajp_connection_tcp_send_message::jk_ajp_common.c (1267): 03f0    57 F3 F4 EC CB E9 49 9B 59 44 AB FE 66 6E 67 DC  - W.....I.YD..fng. [Mon Jun 24 14:37:28 2019] [17826:139891516274752] [debug] ajp_connection_tcp_get_message::jk_ajp_common.c (1462): received from ajp13 pos=0 len=3 max=8192 [Mon Jun 24 14:37:28 2019] [17826:139891516274752] [debug] ajp_connection_tcp_get_message::jk_ajp_common.c (1462): 0000   06 1F FA 00 00 00 00 00 00 00 00 00 00 00 00 00  - ................ [Mon Jun 24 14:37:28 2019] [17826:139891516274752] [info] ajp_read_into_msg_buff::jk_ajp_common.c (1553): (main_ajp13_worker) receiving data from client failed. Connection aborted or network problems [Mon Jun 24 14:37:28 2019] [17826:139891516274752] [info] ajp_process_callback::jk_ajp_common.c (2105): (main_ajp13_worker) Reading from client aborted or client network problems [Mon Jun 24 14:37:28 2019] [17826:139891516274752] [info] ajp_service::jk_ajp_common.c (2778): (main_ajp13_worker) sending request to tomcat failed (unrecoverable), because of client read error (attempt=1) [Mon Jun 24 14:37:28 2019] [17826:139891516274752] [debug] ajp_reset_endpoint::jk_ajp_common.c (851): (main_ajp13_worker) resetting endpoint with socket 24 (socket shutdown) [Mon Jun 24 14:37:28 2019] [17826:139891516274752] [debug] ajp_abort_endpoint::jk_ajp_common.c (821): (main_ajp13_worker) aborting endpoint with socket 24 [Mon Jun 24 14:37:28 2019] [17826:139891516274752] [debug] jk_shutdown_socket::jk_connect.c (932): About to shutdown socket 24 [127.0.0.1:38678 -> 127.0.0.1:8009] [Mon Jun 24 14:37:28 2019] [17826:139891516274752] [debug] jk_shutdown_socket::jk_connect.c (1005): shutting down the read side of socket 24 [127.0.0.1:38678 -> 127.0.0.1:8009] [Mon Jun 24 14:37:28 2019] [17826:139891516274752] [debug] jk_shutdown_socket::jk_connect.c (1016): Shutdown socket 24 [127.0.0.1:38678 -> 127.0.0.1:8009] and read 265 lingering bytes in 0 sec. [Mon Jun 24 14:37:28 2019] [17826:139891516274752] [debug] ajp_done::jk_ajp_common.c (3287): recycling connection pool for worker main_ajp13_worker and socket -1 [Mon Jun 24 14:37:28 2019] [17826:139891516274752] [info] jk_handler::mod_jk.c (2988): Aborting connection for worker=main_ajp13_worker [Mon Jun 24 14:38:24 2019] [17825:139891516274752] [debug] wc_shutdown::jk_worker.c (390): Shutting down worker main_ajp13_worker [Mon Jun 24 14:38:24 2019] [17825:139891516274752] [debug] jk_shm_close::jk_shm.c (745): Closed shared memory /var/log/httpd/mod_jk.shm.17823 childs=9 [Mon Jun 24 14:38:24 2019] [17877:139891516274752] [debug] wc_shutdown::jk_worker.c (390): Shutting down worker main_ajp13_worker 

In the above logs, I counted the number of times the 8k buffer was re-filled (36,856 times), and found that 302,071,776 bytes (62%) of the file was transferred before the error occurred.


My interpretation of the above logs

The SSL handshake is succeeding, and the error occurs after the HTTP 100 Continue, so I suspect that the file has been partially sent prior to the following messages in mod_jk.log:

  • receiving data from client failed. Connection aborted or network problems
  • sending request to tomcat failed (unrecoverable), because of client read error (attempt=1)

Since there are no errors in catalina.out, and mod/jk is complaining about a client read error, I believe this rules out Tomcat itself (and the web application, Artifactory).

Most of the comments I see with a Google search on the above mod/jk messages state that they are transient network errors, but I’m not buying that since these are file transfers between to EC2 instances in the same region. I am also interpreting this as not having anything to do with a connection timeout, as that would (I think) produce a “Connection timed out after n milliseconds” message.

As a final test, I bypassed Apache HTTPD and mod/jk by uploading directly to Tomcat via port 8443 (still using SSL). These requests succeeded every time. This leads me to believe that the problem is with Apache HTTPD and/or mod/jk, and is not caused by “transient network errors”.


My Question

Are there any configuration options that I should look into for HTTPD and/or mod/jk to eliminate these problems?

Alternatively, is there any way to tell curl (and/or mod/jk) to attempt to handle these failed buffer re-fills in a fault tolerant way, so that the uploads can successfully complete?

CURL Post Request to PayPal NVP/SOAP API [on hold]

curl POST -d USER=[email] -d PWD=[password] -d SIGNATURE=[signature] -d METHOD=TransactionSearch -d TRANSACTIONCLASS=RECEIVED -d STARTDATE=2019-05-21T05:38:48Z -d ENDDATE=2019-05-22T05:38:48Z -d VERSION=94  https://api-3t.paypal.com/nvp  curl: (6) Could not resolve host: POST  TIMESTAMP=2019%2d06%2d19T15%3a00%3a11Z&CORRELATIONID=8439e637f94&ACK=Failure&VERSION=94&BUILD=52546130&L_ERRORCODE0=10002&L_SHORTMESSAGE0=Security%20error&L_LONGMESSAGE0=Security%20header%20is%20not%20valid&L_SEVERITYCODE0=Error%   

Hey All,

I’m posting about CURL POST requests I have been making to the PayPal NVP/SOAP API. Above I have the curl request itself followed by the response from the prompt below. I have tried this call many different ways such as without the -3t in the domain, concatenating all arguments in the request into a string separated by & as well as various permutations of those. For some context I’m just trying to get an ordered list of all transactions from my company within a given timeframe with minimal calls to the API. This seem(ed)s the best, most efficient way to go about it. Any insights, or pointers at all as to why this doesn’t work or about the NVP/SOAP API generally would be greatly appreciated. Alternatively code for successful curl requests made to this API would also be appreciated.

Thank you,

Alex