Newbie Trying to Connect, getting 401 Unauthorized from Guzzlehttp

800 views
Skip to first unread message

Dave Conroy

unread,
May 3, 2015, 5:36:19 PM5/3/15
to phr...@googlegroups.com
Hello Everyone,
My name is Dave Conroy and I am trying to work with the RETS standard for the first time.

I've acquired credentials to a local MLS RETS feed and can verify it is working with RETSMD attached and linked.


When I try and use the sample code to connect I get a 401 Unauthorized from guzzlehttp. I've attached the sample code I used, and the error below. Any help at all would be appreciated. Thanks so much,

Dave Conroy



Link to code:


<?php

date_default_timezone_set('America/New_York');

require_once("vendor/autoload.php");

$log = new \Monolog\Logger('PHRETS');
$log->pushHandler(new \Monolog\Handler\StreamHandler('app.log', \Monolog\Logger::DEBUG));

$rets_username='###';
$rets_password='###';

$config = new \PHRETS\Configuration;
$config->setLoginUrl($rets_login_url);
$config->setUsername($rets_username);
$config->setPassword($rets_password);

// optional.  value shown below are the defaults used when not overridden
$config->setRetsVersion('1.5'); // see constants from \PHRETS\Versions\RETSVersion
$config->setUserAgent('UserAgent/1.0');


$rets = new \PHRETS\Session($config);

echo "Config loaded, trying to login<br>";
$connect = $rets->Login();



echo "EOF";

-------------------------

Error printout below.

[03-May-2015 17:12:52 America/New_York] PHP Fatal error:  Uncaught exception 'GuzzleHttp\Exception\ClientException' with message 'Client error response [url] https://bridge-rets.mlspin.com:12109/rets/login [status code] 401 [reason phrase] Unauthorized' in /Volumes/Data/Dropbox/AWS/phrets/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:68


Stack trace:

#0 /Volumes/Data/Dropbox/AWS/phrets/vendor/guzzlehttp/guzzle/src/Subscriber/HttpError.php(31): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Message\Request), Object(GuzzleHttp\Message\Response))

#1 /Volumes/Data/Dropbox/AWS/phrets/vendor/guzzlehttp/guzzle/src/Event/Emitter.php(105): GuzzleHttp\Subscriber\HttpError->onComplete(Object(GuzzleHttp\Event\CompleteEvent), 'complete')

#2 /Volumes/Data/Dropbox/AWS/phrets/vendor/guzzlehttp/guzzle/src/Event/RequestEvents.php(75): GuzzleHttp\Event\Emitter->emit('complete', Object(GuzzleHttp\Event\CompleteEvent))

#3 /Volumes/Data/Dropbox/AWS/phrets/vendor/guzzlehttp/guzzle/src/Adapter/Curl/CurlAdapter.php(94): GuzzleHttp\Event\RequestEvents::emitCompl in /Volumes/Data/Dropbox/AWS/phrets/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 68

Screen Shot 2015-05-03 at 5.11.16 PM.png

Troy Davisson

unread,
May 4, 2015, 8:56:30 PM5/4/15
to phr...@googlegroups.com
I've added a remedy to version 2.1 which allows this to work.  The server only seems to support HTTP Basic authentication, so PHRETS now allows you to use that specifically instead of Digest (the default).

--
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.

Dave Conroy

unread,
May 4, 2015, 10:35:22 PM5/4/15
to phr...@googlegroups.com
Confirmed, that the update fixed it. Thanks Troy!

carena...@gmail.com

unread,
Apr 10, 2018, 10:23:16 AM4/10/18
to PHRETS
Hi,

I just want to ask if what is the remedy to this problem?
I am having the same issue.

Thank you so much.

ra...@thebestmedia.com

unread,
Feb 4, 2019, 10:03:19 AM2/4/19
to PHRETS
I have an error connecting though. I am using PHRETS/2.6.1
Check my code below.

$rets_username = $data['rets_username'];
        $rets_password = $data['rets_password'];
        $rets_login_url = $data['rets_login_url'];
        $em = $this->getDoctrine()->getManager();
        $config = new \PHRETS\Configuration;
       
        $config->setLoginUrl($rets_login_url)
        ->setUsername($rets_username)
        ->setPassword($rets_password)
        ->setRetsVersion('1.5')
        ->setUserAgent('PHRETS/2.6.1');

        //dump($config);
        $rets = new \PHRETS\Session($config);
        //dump("RETS Details");
        //dump($rets);
        $connect = $rets->Login();


It does not connect. It gives me 500 internal server error. I tried printing the connect variable. It does not print anything.

The error log

request.CRITICAL: Uncaught PHP Exception GuzzleHttp\Exception\ConnectException: "cURL error 7: Failed to connect to retsau.torontomls.net port 6103: Connection refused (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)" at /home/thebestmedia/public_html/treb/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php line 185 {"exception":"[object] (GuzzleHttp\\Exception\\ConnectException(code: 0): cURL error 7: Failed to connect to retsau.torontomls.net port 6103: Connection refused (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) at /home/thebestmedia/public_html/treb/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:185)"} []
[2019-02-04 14:55:37] cache.WARNING: Failed to save key "%5BSymfony%5CBundle%5CTwigBundle%5CController%5CExceptionController%5D%5B1%5D" (array) {"key":"%5BSymfony%5CBundle%5CTwigBundle%5CController%5CExceptionController%5D%5B1%5D","type":"array","exception":"[object] (ErrorException(code: 0): file_put_contents(/home/thebestmedia/public_html/treb/var/cache/prod/pools/-JrF9zn+fM/5c585269300a19.01882632): failed to open stream: Permission denied at /home/thebestmedia/public_html/treb/vendor/symfony/cache/Traits/FilesystemCommonTrait.php:92)"} []
[2019-02-04 14:55:37] cache.WARNING: Failed to save key "%5BSymfony%5CBundle%5CTwigBundle%5CController%5CExceptionController%23showAction%5D%5B1%5D" (array) {"key":"%5BSymfony%5CBundle%5CTwigBundle%5CController%5CExceptionController%23showAction%5D%5B1%5D","type":"array","exception":"[object] (ErrorException(code: 0): file_put_contents(/home/thebestmedia/public_html/treb/var/cache/prod/pools/-JrF9zn+fM/5c585269300a19.01882632): failed to open stream: Permission denied at /home/thebestmedia/public_html/treb/vendor/symfony/cache/Traits/FilesystemCommonTrait.php:92)"} []

Is the CURL lib missing or any problen. I just checked using Phpinfo() on the server and CURL is enabled.
Reply all
Reply to author
Forward
0 new messages