Skip to content

Commit

Permalink
Merge pull request #120 from robmachado/master
Browse files Browse the repository at this point in the history
aumentado o tempo de timeout
  • Loading branch information
robmachado authored Aug 23, 2023
2 parents 0a61d38 + 7e2714e commit 16a2370
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 21 deletions.
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 @@ abstract class SoapBase implements SoapInterface
/**
* @var int
*/
protected $soaptimeout = 20;
protected $soaptimeout = 60;
/**
* @var string
*/
Expand Down Expand Up @@ -138,6 +138,10 @@ abstract class SoapBase implements SoapInterface
* @var string
*/
public $soaperror;
/**
* @var string
*/
public $soaperrorno;
/**
* @var array
*/
Expand All @@ -160,7 +164,7 @@ public function __construct(
$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 @@ private function checkCertValidity(Certificate $certificate = null)
}
return $certificate;
}

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

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

/**
* ONlY for tests
* @param bool $flag
Expand All @@ -222,7 +226,7 @@ public function loadCA($capath)
$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 @@ public function setEncriptPrivateKey($encript = true)
{
return $this->encriptPrivateKey = $encript;
}

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

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

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

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

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

/**
* Set security protocol
* @param int $protocol
Expand All @@ -300,7 +304,7 @@ public function protocol($protocol = self::SSL_DEFAULT)
{
return $this->soapprotocol = $protocol;
}

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

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

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

/**
* Mount soap envelope
* @param string $request
Expand Down Expand Up @@ -372,7 +376,7 @@ protected function makeEnvelopeSoap(
. "</$prefix:Envelope>";
return $envelope;
}

/**
* Temporarily saves the certificate keys for use cURL or SoapClient
*/
Expand Down Expand Up @@ -419,7 +423,7 @@ public function saveTemporarilyKeyFiles()
);
}
}

/**
* Delete all files in folder
*/
Expand Down Expand Up @@ -457,7 +461,7 @@ public function removeTemporarilyFiles()
}
}
}

/**
* Save request envelope and response for debug reasons
* @param string $operation
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 @@ -85,6 +85,7 @@ public function send(
}
$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 @@ public function send(
$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

0 comments on commit 16a2370

Please sign in to comment.