Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aumentado o tempo de timeout #120

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 23 additions & 19 deletions src/Common/Soap/SoapBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/**
* @var int
*/
protected $soaptimeout = 20;
protected $soaptimeout = 60;
/**
* @var string
*/
Expand Down Expand Up @@ -138,6 +138,10 @@
* @var string
*/
public $soaperror;
/**
* @var string
*/
public $soaperrorno;
/**
* @var array
*/
Expand All @@ -160,7 +164,7 @@
$this->certificate = $this->checkCertValidity($certificate);
$this->setTemporaryFolder(sys_get_temp_dir() . '/sped/');
}

/**
* Check if certificate is valid
* @param Certificate $certificate
Expand All @@ -181,7 +185,7 @@
}
return $certificate;
}

/**
* Destructor
* Clean temporary files
Expand All @@ -190,7 +194,7 @@
{
$this->removeTemporarilyFiles();
}

/**
* Disables the security checking of host and peer certificates
* @param bool $flag
Expand All @@ -200,7 +204,7 @@
$this->disablesec = $flag;
return $this->disablesec;
}

/**
* ONlY for tests
* @param bool $flag
Expand All @@ -222,7 +226,7 @@
$this->casefaz = $capath;
}
}

/**
* Set option to encript private key before save in filesystem
* for an additional layer of protection
Expand All @@ -233,7 +237,7 @@
{
return $this->encriptPrivateKey = $encript;
}

/**
* Set another temporayfolder for saving certificates for SOAP utilization
* @param string $folderRealPath
Expand All @@ -243,7 +247,7 @@
$this->tempdir = $folderRealPath;
$this->setLocalFolder($folderRealPath);
}

/**
* Set Local folder for flysystem
* @param string $folder
Expand All @@ -263,7 +267,7 @@
{
return $this->debugmode = $value;
}

/**
* Set certificate class for SSL comunications
* @param Certificate $certificate
Expand All @@ -272,7 +276,7 @@
{
$this->certificate = $this->checkCertValidity($certificate);
}

/**
* Set logger class
* @param LoggerInterface $logger
Expand All @@ -281,7 +285,7 @@
{
return $this->logger = $logger;
}

/**
* Set timeout for communication
* @param int $timesecs
Expand All @@ -290,7 +294,7 @@
{
return $this->soaptimeout = $timesecs;
}

/**
* Set security protocol
* @param int $protocol
Expand All @@ -300,7 +304,7 @@
{
return $this->soapprotocol = $protocol;
}

/**
* Set prefixes
* @param array $prefixes
Expand All @@ -310,7 +314,7 @@
{
return $this->prefixes = $prefixes;
}

/**
* Set proxy parameters
* @param string $ip
Expand All @@ -325,7 +329,7 @@
$this->proxyUser = $user;
$this->proxyPass = $password;
}

/**
* Send message to webservice
*/
Expand All @@ -336,7 +340,7 @@
$envelope,
$parameters
);

/**
* Mount soap envelope
* @param string $request
Expand All @@ -359,10 +363,10 @@
$soapheader = "<$prefix:Header/>";
if (!empty($header)) {
$ns = !empty($header->namespace) ? $header->namespace : '';
$name = $header->name;

Check failure on line 366 in src/Common/Soap/SoapBase.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (7.4)

Access to an undefined property SoapHeader::$name.

Check failure on line 366 in src/Common/Soap/SoapBase.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (8.0)

Access to an undefined property SoapHeader::$name.
$soapheader = "<$prefix:Header>";
$soapheader .= "<$name xmlns=\"$ns\">";
foreach ($header->data as $key => $value) {

Check failure on line 369 in src/Common/Soap/SoapBase.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (7.4)

Access to an undefined property SoapHeader::$data.

Check failure on line 369 in src/Common/Soap/SoapBase.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (8.0)

Access to an undefined property SoapHeader::$data.
$soapheader .= "<$key>$value</$key>";
}
$soapheader .= "</$name></$prefix:Header>";
Expand All @@ -372,7 +376,7 @@
. "</$prefix:Envelope>";
return $envelope;
}

/**
* Temporarily saves the certificate keys for use cURL or SoapClient
*/
Expand All @@ -396,7 +400,7 @@
$this->temppass = Strings::randomString(16);
//encripta a chave privada entes da gravação do filesystem
openssl_pkey_export(
$this->certificate->privateKey,

Check failure on line 403 in src/Common/Soap/SoapBase.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (7.4)

Parameter #1 $key of function openssl_pkey_export expects resource, NFePHP\Common\Certificate\PrivateKey given.
$private,
$this->temppass
);
Expand All @@ -419,7 +423,7 @@
);
}
}

/**
* Delete all files in folder
*/
Expand Down Expand Up @@ -457,7 +461,7 @@
}
}
}

/**
* Save request envelope and response for debug reasons
* @param string $operation
Expand All @@ -475,7 +479,7 @@
$cnpj = $this->certificate->getCnpj();
}
$this->debugdir = $cnpj() . '/debug/';
$now = \DateTime::createFromFormat('U.u', microtime(true));

Check failure on line 482 in src/Common/Soap/SoapBase.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (7.4)

Parameter #2 $datetime of static method DateTime::createFromFormat() expects string, float given.

Check failure on line 482 in src/Common/Soap/SoapBase.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (8.0)

Parameter #2 $datetime of static method DateTime::createFromFormat() expects string, float given.

Check failure on line 482 in src/Common/Soap/SoapBase.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (8.1)

Parameter #2 $datetime of static method DateTime::createFromFormat() expects string, float given.
$time = substr($now->format("ymdHisu"), 0, 16);
try {
$this->filesystem->put(
Expand Down
7 changes: 5 additions & 2 deletions src/Common/Soap/SoapCurl.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, 0);
if (!$this->disablesec) {
curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, 2);
if (is_file($this->casefaz ?? '')) {

Check failure on line 70 in src/Common/Soap/SoapCurl.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (7.4)

Property NFePHP\eFinanc\Common\Soap\SoapBase::$casefaz (string) on left side of ?? is not nullable.

Check failure on line 70 in src/Common/Soap/SoapCurl.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (8.0)

Property NFePHP\eFinanc\Common\Soap\SoapBase::$casefaz (string) on left side of ?? is not nullable.

Check failure on line 70 in src/Common/Soap/SoapCurl.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (8.1)

Property NFePHP\eFinanc\Common\Soap\SoapBase::$casefaz (string) on left side of ?? is not nullable.
curl_setopt($oCurl, CURLOPT_CAINFO, $this->casefaz);
}
}
Expand All @@ -85,6 +85,7 @@
}
$response = curl_exec($oCurl);
$this->soaperror = curl_error($oCurl);
$this->soaperrorno = (string) curl_errno($oCurl);
$ainfo = curl_getinfo($oCurl);
if (is_array($ainfo)) {
$this->soapinfo = $ainfo;
Expand All @@ -100,10 +101,12 @@
$this->responseHead . "\n" . $this->responseBody
);
} catch (\Exception $e) {
throw SoapException::unableToLoadCurl($e->getMessage());
throw new SoapException('LIBCURL não localizada', 500);
//::unableToLoadCurl($e->getMessage(), 500);
}
if ($this->soaperror != '') {
throw SoapException::soapFault($this->soaperror . " [$url]", $this->soaperror);
throw new SoapException($this->soaperror . " [$url]", $this->soaperrorno);

Check failure on line 108 in src/Common/Soap/SoapCurl.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (7.4)

Parameter #2 $code of class NFePHP\Common\Exception\SoapException constructor expects int, string given.

Check failure on line 108 in src/Common/Soap/SoapCurl.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (8.0)

Parameter #2 $code of class NFePHP\Common\Exception\SoapException constructor expects int, string given.

Check failure on line 108 in src/Common/Soap/SoapCurl.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (8.1)

Parameter #2 $code of class NFePHP\Common\Exception\SoapException constructor expects int, string given.
//::soapFault($this->soaperror . " [$url]", $this->soaperror);
}
if ($httpcode != 200) {
throw SoapException::soapFault(
Expand Down Expand Up @@ -158,9 +161,9 @@
private function setCurlProxy(&$oCurl)
{
if ($this->proxyIP != '') {
curl_setopt($oCurl, CURLOPT_HTTPPROXYTUNNEL, 1);

Check failure on line 164 in src/Common/Soap/SoapCurl.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (8.0)

Parameter #1 $handle of function curl_setopt expects CurlHandle, resource given.

Check failure on line 164 in src/Common/Soap/SoapCurl.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (8.1)

Parameter #1 $handle of function curl_setopt expects CurlHandle, resource given.
curl_setopt($oCurl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);

Check failure on line 165 in src/Common/Soap/SoapCurl.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (8.1)

Parameter #1 $handle of function curl_setopt expects CurlHandle, resource given.
curl_setopt($oCurl, CURLOPT_PROXY, $this->proxyIP.':'.$this->proxyPort);

Check failure on line 166 in src/Common/Soap/SoapCurl.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (8.1)

Parameter #1 $handle of function curl_setopt expects CurlHandle, resource given.
if ($this->proxyUser != '') {
curl_setopt($oCurl, CURLOPT_PROXYUSERPWD, $this->proxyUser.':'.$this->proxyPass);
curl_setopt($oCurl, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
Expand Down
Loading