metaregistrar / php-epp-client

Object-oriented PHP EPP Client
https://www.metaregistrar.com/docs/
MIT License
213 stars 156 forks source link

Unexpected closed connection #73

Closed alexrsagen closed 7 years ago

alexrsagen commented 7 years ago

I haven't been able to connect to Norid's EPP server. Upon enabling logging, i receive the message "Unexpected closed connection by remote host..." which i found from reading eppConnection.php is produced upon an unexpected end-of-file.

I contacted the registry (Norid) and asked if they have any idea why i would be getting an unexpected closed connection, and they replied saying i probably forgot to add the 32-bit header which dictates the length of the data being sent. However, i clearly see that header being added. I even verified it by adding print(bin2hex($content)) to the write function in eppConnection.php. The first 4 bytes are 00 00 05 0b (decimal: 1291) when the length of the rest of my content is 1287 bytes. Seems perfectly fine to me.

I don't see why it would be sending an end-of-file early as everything seems to be done correctly. Please let me know if you have any idea why that is, @metaregistrar.

Here is the code i use to connect to Norid:

$this->connection = new noridEppConnection(true);
$this->connection->setHostname('epp.test.norid.no'); // Norid EPP test server
$this->connection->setPort(700);
$this->connection->setUsername($myusername);
$this->connection->setPassword($mypassword);
if (!$this->connection->login()) {
    // throw an exception here
}

I have verified that $myusername and $mypassword are correct by signing into their web-based EPP client using the same credentials successfully.

After connecting, i'd make a request like this in another class function that returns the expiration date of a domain:

// eppDomain would also work here because i'm not using the extensions
// I'm only using noridEppDomain here for consistency
$domain = new noridEppDomain('example.no');
$request = new eppInfoDomainRequest($domain);

if ($response = $this->connection->request($request)) {
    /* @var $response Metaregistrar\EPP\eppInfoDomainResponse */

    if ($response->getResultCode() == eppResponse::RESULT_SUCCESS) {
        return strtotime($response->getDomainExpirationDate());
    } else {
        // throw an exception here
    }
} else {
    // throw an exception here
}
metaregistrar commented 7 years ago

Hello Alexander,

Can you try to connect to $this->connection->setHostname('ssl:// epp.test.norid.no'); and see if that works?

The problem may also be that your IP address has to be whitelisted in Norid's servers, we also see that a lot of times when 'unexpected end of connection' is thrown.

Vriendelijke groeten/kind regards,

Ewout de Graaf Metaregistrar

2017-01-19 12:00 GMT+01:00 Alexander Sagen notifications@github.com:

I haven't been able to connect to Norid's EPP server. Upon enabling logging, i receive the message "Unexpected closed connection by remote host..." which i found from reading eppConnection.php is produced upon an unexpected end-of-file.

I contacted the registry (Norid) and asked if they have any idea why i would be getting an unexpected closed connection, and they replied saying i probably forgot to add the 32-bit header which dictates the length of the data being sent. However, i clearly see that header being added. I even verified it by adding print(bin2hex($content)) to the write function in eppConnection.php. The first 4 bytes are 00 00 05 0b (decimal: 1291) when the length of the rest of my content is 1287 bytes. Seems perfectly fine to me.

I don't see why it would be sending an end-of-file early as everything seems to be done correctly. Please let me know if you have any idea why that is, @metaregistrar https://github.com/metaregistrar.

Here is the code i use to connect to Norid:

$this->connection = new noridEppConnection(true);$this->connection->setHostname('epp.test.norid.no'); // Norid EPP test server$this->connection->setPort(700);$this->connection->setUsername($myusername);$this->connection->setPassword($mypassword);if (!$this->connection->login()) { // throw an exception here}

I have verified that $myusername and $mypassword are correct by signing into their web-based EPP client using the same credentials successfully.

After connecting, i'd make a request like this in another class function that returns the expiration date of a domain:

// eppDomain would also work here because i'm not using the extensions// I'm only using noridEppDomain here for consistency$domain = new noridEppDomain('example.no');$request = new eppInfoDomainRequest($domain);if ($response = $this->connection->request($request)) { / @var $response Metaregistrar\EPP\eppInfoDomainResponse / if ($response->getResultCode() == eppResponse::RESULT_SUCCESS) { return strtotime($response->getDomainExpirationDate()); } else { // throw an exception here }} else { // throw an exception here}

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/metaregistrar/php-epp-client/issues/73, or mute the thread https://github.com/notifications/unsubscribe-auth/ADR1Wlwcwl66jIEqtRns81kBTbGCkNLvks5rT0JogaJpZM4Ln-CN .

alexrsagen commented 7 years ago

Thank you for the quick reply! The connection is working when i prepend the hostname with ssl://.