Unable to connect to RETS test server

486 views
Skip to first unread message

Graham Golder

unread,
Oct 16, 2015, 3:36:09 PM10/16/15
to PHRETS
Hi All,

I'm trying to connect to a public RETS test server (http://www.mris.com/sites/default/files/pdfs/Agent-Application.June2014.pdf)

Both the sample code for PHRETS 2 and 1.x fail to connect for me (with the same HTTP 400 response).  I have verified that the server is running, and other tools (such as the CoreLogic Connector tool) can connect.

Sample output:
--------------------------------------
$response_body
: string = "<RETS ReplyCode=\"20036\" ReplyText=\"V2.7.0 4489: Realm value is invalid from the Authorization Request Header Argument\">\r\n</RETS>\r\n\r\n"

$this->last_response_headers
: array =
  HTTP: string = "HTTP/1.1 400 Bad Request"
  Server: string = "nginx"
  Date: string = "Fri, 16 Oct 2015 02:04:06 GMT"
  Content-Type: string = "text/plain;charset=ISO-8859-1"
  Content-Length: string = "0"
  Connection: string = "keep-alive"
  Keep-Alive: string = "timeout=20"
  X-Copyright: string = "Copyright 2015 Metropolitan Regional Information Systems, Inc., unauthorized use is prohibited."
  Cache-Control: string = "private"
  RETS-Version: string = "RETS/1.7.2"
  WWW-Authenticate: string = "Digest realm=\"us...@mris.com\", nonce=\"31343434393631303436373737202b5b625ffcdb9e07606f7e5efa1b1999\", opaque=\"6e6f742075736564\""
  Transfer-Encoding: string = "chunked"

-----------------------------------
PHRETS 2.x code sample:

<?php

$rets_login_url = "http://ptest.mris.com:6103/ptest/login" ;
$rets_username = 'MRISTEST';
$rets_password = 'PMRISTEST';
$ver = "RETS/1.7.2";     
$user_agent = "RETS Test/1.0";

date_default_timezone_set('America/New_York');

require_once("vendor/autoload.php");
     
$config = new \PHRETS\Configuration;
$config->setLoginUrl($rets_login_url);
$config->setUsername($rets_username);
$config->setPassword($rets_password);

$config->setRetsVersion('1.7.2');
$config->setUserAgent($user_agent);
$config->setHttpAuthenticationMethod('digest');
$config->setOption('use_post_method', false);
$config->setOption('disable_follow_location', true);

$rets = new \PHRETS\Session($config);
$connect = $rets->Login();
 
?>

----------------------------------------
PHRETS 1.x code sample:

<?php

$login = 'http://ptest.mris.com:6103/ptest/login';         
$un = 'MRISTEST';
$pw = 'PMRISTEST';
$ver = "RETS/1.7.2";
$user_agent = "RETS Test/1.0";

$rets = new PHRETS;
$rets->AddHeader("User-Agent", $user_agent);
$rets->AddHeader("RETS-Version", "RETS/1.7.2");

/* Connect */
$connect = $rets->Connect($login, $un, $pw);

if($connect) {
    $types = $rets->GetMetadataTypes();
    print_r($types);
    $rets->Disconnect();
} else {
    $error = $rets->Error();
    print_r($error);
}

?>
---------------------------

Suggestions?  It seems like this code should work, and that I must be overlooking something.

Environment: Env: PHP 5.5.25; win10 x64


Thanks in advance-
Graham



justin maurer

unread,
Oct 17, 2015, 12:42:42 PM10/17/15
to PHRETS
I'm new here, but is there a chance it's as simple as removing the space in the user agent field (i.e. "RETSTest/1.0")? Not sure if that's a thing, but on mine, there's no space. 

Graham Golder

unread,
Oct 17, 2015, 4:35:48 PM10/17/15
to PHRETS
Unfortunately, that's not it.  I have verified I can connect with other tools using this info, but not with PHRETS.

I'm curious - can anyone else connect to the server with these login credentials?  If so, then that helps narrow down the problem-

thanks-

Troy Davisson

unread,
Oct 17, 2015, 4:46:32 PM10/17/15
to PHRETS

Try http://retsmd.com/auth/ which uses PHRETS.

It appears to work for me.


--
You received this message because you are subscribed to the Google Groups "PHRETS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phrets+un...@googlegroups.com.
To post to this group, send email to phr...@googlegroups.com.
Visit this group at http://groups.google.com/group/phrets.
For more options, visit https://groups.google.com/d/optout.

Graham Golder

unread,
Oct 17, 2015, 6:24:43 PM10/17/15
to PHRETS
Thanks for sending that link; it works for me also.

That means that the problem is something with my local env (which is odd, since everything else works fine).  I'm not sure what would cause the realm value/authorization headers to be incorrect.

I have everything from composer.phar, and am not seeing any warnings or exceptions when running.    Are there any dependencies on versions of SSL, or other extensions?   I'm running php 5.5.25 (32bit); see attachment for more details.

Thanks for the help-
php_settings.txt

Graham Golder

unread,
Oct 18, 2015, 6:10:38 PM10/18/15
to PHRETS
The PHRETS sample code does work on Ubuntu fine, but the same code doesn't work on Windows.

The difference is in the request headers - on Windows, CURL is not setting the "realm" value (but does set it on Linux):
  
*** UBUNTU ***
[request_header] => GET /ptest/login HTTP/1.1
Authorization: Digest username="MRISTEST", realm="us...@mris.com", nonce="313434353230343031323133302019d5412ecc0829e5b338e252a82858b1", uri="/ptest/login", response="13015db6f916a2511ca5de8ff52d9f96", opaque="6e6f742075736564"
Host: ptest.mris.com:6103
Accept: */*
User-Agent: RETS Test/1.0
RETS-Version: RETS/1.7.2


*** WINDOWS ***
[request_header] => GET /ptest/login HTTP/1.1
Host: ptest.mris.com:6103
Authorization: Digest username="MRISTEST",realm="",nonce="3134343532303338353034303920c0b894b068524c338e3052ff750f99b1",uri="/ptest/login",response="372e8adcf627196320afba0ca6ecda8a",opaque="6e6f742075736564"
Accept: */*
User-Agent: RETS Test/1.0
RETS-Version: RETS/1.7.2


So then the question is - is there a way to forcibly add the missing 'realm' value for Windows?

(Bug occurs on both the latest versions of PHP for windows - 5.5.30 and 5.6.14).

Graham Golder

unread,
Oct 18, 2015, 6:58:26 PM10/18/15
to PHRETS
This is apparently a known Windows bug:
- http://curl.haxx.se/mail/tracker-2015-02/0045.html
- https://github.com/msysgit/msysgit/issues/311

The solution is to add the realm to the username, so for the server below the username would be: 'us...@mris.com\MRISTEST', instead of "MRISTEST'.
Reply all
Reply to author
Forward
0 new messages