Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session expired while logging in #178

Closed
dfbravo opened this issue Nov 7, 2017 · 2 comments
Closed

Session expired while logging in #178

dfbravo opened this issue Nov 7, 2017 · 2 comments

Comments

@dfbravo
Copy link

dfbravo commented Nov 7, 2017

I am new to using RETS and this libary. I am attempting to log into a RETS server following the example code:

<?php
date_default_timezone_set('AmericaNey York');

require_once("vendor/autoload.php");

$config = new \PHRETS\Configuration;
$config->setLoginUrl('RETS_URL')
        ->setUsername('username')
        ->setPassword('password')
        ->setOption('use_post_method', true)
        ->setHttpAuthenticationMethod('basic')
        ->setOption('disable_follow_location', false)
        ->setRetsVersion('1.7');
$rets = new \PHRETS\Session($config);

// If you're using Monolog already for logging, you can pass that logging instance to PHRETS for some additional
// insight into what PHRETS is doing.
//
$log = new \Monolog\Logger('PHRETS');
$log->pushHandler(new \Monolog\Handler\StreamHandler('php://stdout', \Monolog\Logger::DEBUG));
$log->pushHandler(new \Monolog\Handler\StreamHandler('./sample_log.log', \Monolog\Logger::DEBUG));
$rets->setLogger($log);

$connect = $rets->Login();
?>

Output:

[2017-11-07 14:45:06] PHRETS.DEBUG: Loading Monolog\Logger logger [] []
PHP Notice:  Use of undefined constant CURLOPT_COOKIEFILE - assumed 'CURLOPT_COOKIEFILE' in /var/www/html/rets_test/vendor/troydavisson/phrets/src/Session.php on line 545
[2017-11-07 14:45:06] PHRETS.DEBUG: Sending HTTP Request for RETS URL (Login) {"auth":["username","password","basic"],"headers":{"User-Agent":"PHRETS/2.0","RETS-Version":"RETS/1.7","Accept-Encoding":"gzip","Accept":"*/*"},"curl":{"CURLOPT_COOKIEFILE":"/tmp/phretssrQnXg"}} []
[2017-11-07 14:45:06] PHRETS.DEBUG: Using POST method per use_post_method option [] []
[2017-11-07 14:45:07] PHRETS.DEBUG: Response: HTTP 200 [] []
PHP Notice:  Use of undefined constant CURLOPT_COOKIEFILE - assumed 'CURLOPT_COOKIEFILE' in /var/www/html/rets_test/vendor/troydavisson/phrets/src/Session.php on line 545
[2017-11-07 14:45:07] PHRETS.DEBUG: Sending HTTP Request for http://rets.torontomls.net:6103/rets-treb3pv/server/action (Action) {"auth":["D17bor_a","B93t#45","basic"],"headers":{"User-Agent":"PHRETS/2.0","RETS-Version":"RETS/1.7","Accept-Encoding":"gzip","Accept":"*/*"},"curl":{"CURLOPT_COOKIEFILE":"/tmp/phretsYPjqjn"}} []
[2017-11-07 14:45:07] PHRETS.DEBUG: Using POST method per use_post_method option [] []
[2017-11-07 14:45:07] PHRETS.DEBUG: Response: HTTP 200 [] []
PHP Fatal error:  Uncaught PHRETS\Exceptions\RETSException: The session has expired in /var/www/html/rets_test/vendor/troydavisson/phrets/src/Session.php:423
Stack trace:
#0 /var/www/html/rets_test/vendor/troydavisson/phrets/src/Session.php(87): PHRETS\Session->request('Action')
#1 /var/www/html/rets_test/main.php(26): PHRETS\Session->Login()
#2 {main}
  thrown in /var/www/html/rets_test/vendor/troydavisson/phrets/src/Session.php on line 423

The issue occurs in the Login() function of \PHRETS\Session. I don't know where to start debugging this issue. I think the connection expires during the time it takes for the login function to finish. I don't know if there is an option I can set in the Http request to prevent the session from ending so quickly.

In my attempt to debug I added some print messages and found out the ReplyCode is 200052.

Any advice on how to proceed? Is this a user error? A server setting?

Cheers.

@steveheinsch
Copy link

steveheinsch commented Nov 7, 2017

1 - REMOVE YOUR LOGIN INFO FROM THE Output. Your username/password is included.
2 - timezone should be "America/New_York"
3 - Do you have the php_curl extension enabled in your php.ini? The error messages suggest curl isn't available (Use of undefined constant CURLOPT_COOKIEFILE)

@dfbravo
Copy link
Author

dfbravo commented Nov 9, 2017

Thanks for response. Installing the php curl package made it work.

@dfbravo dfbravo closed this as completed Nov 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants