I want to send XML requests via EPP protocole to a registrar and get responses, the connection is successful, but when I get to fread($fp)
, it takes forever to load.
Is there a way to make it fast and get a response from the registrar?
I am using the code bellow in a hostbill plugin.
/** open socket* */
$fp = fsockopen("tcp://registrarwebsite.com", 700, $errno, $errstr, 200);
stream_set_blocking($fp, true);
stream_context_set_option($fp, 'ssl', 'verify_host', true);
stream_context_set_option($fp, 'ssl', 'verify_peer', true);
stream_context_set_option($fp, 'ssl', 'allow_self_signed', false);
stream_context_set_option($fp, 'ssl', 'local_cert', __DIR__ . '/ma_cert.pem');
stream_context_set_option($fp, 'ssl', 'local_pk', __DIR__ . '/ma_key.pem');
// $secure = stream_socket_enable_crypto($fp, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
// stream_set_blocking($fp, false);
if (!$fp) {
$this->addError('Il y a une erreur dans la connexion: ' . $errno . ' ' . $errstr);
return false;
} else {
$xml = htmlentities($this->prepareXMLRequest($xml));
fwrite($fp, $xml);
$out = fread($fp, 1024);
fclose($fp);
$out1 = htmlentities($fp);
$this->addError('<span style="color: green !important">Connexion se fait avec succes, le code retourné est : </span> ' . $out1);