php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44134 sessions calling causes timeout and failed response in simplexml and curl
Submitted: 2008-02-15 23:19 UTC Modified: 2008-02-25 17:58 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: doc+phpbugs at skynet dot ie Assigned:
Status: Closed Package: Session related
PHP Version: 5.2.5 OS: ubuntu linux
Private report: No CVE-ID: None
 [2008-02-15 23:19 UTC] doc+phpbugs at skynet dot ie
Description:
------------
When I pass a parameter of session_name()=session_id() in a url or as a header and use curl  or simplexml the connection times out. I get the following response from simplexml_load_file($url).

failed to open stream: HTTP request failed!

However, when I connect to the same url with curl on the commandline I get the expected response immediately.



Reproduce code:
---------------
echo $data_source_url = DATAURL.'?bget=1&'.session_name().'='.session_id().'&basket_id='.clean_from_db($basket_id);
$basket_details = simplexml_load_file($data_source_url);

I also get the same when I use:
$ch=curl_init();
echo $this->URL.$this->XMLRequest.'?'.$urlstring;
curl_setopt($ch, CURLOPT_URL,$this->URL.$this->XMLRequest.'?'.$urlstring);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);

or pass it as a more standard CURLOPT_HTTPHEADER to curl_setopt.

Expected result:
----------------
To retrieve xml from the server.

Actual result:
--------------
The page is called which then attempts to connect to the data url, that stalls for some time then calls the server correctly then the script eventually times out.

I've used wireshark on the machine and it's calling the url correctly and getting the expected response, as I can see the xml being passed back, but somewhere between then and actually returning, it stalls and times out.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-18 09:36 UTC] jani@php.net
Please provide a proper reproducing script. The one here is not enough.
Proper script is 100% self-contained and starts with <?php and ends with  ?> (for the sake of being clear where the script really ends :)
 [2008-02-18 18:55 UTC] doc+phpbugs at skynet dot ie
<?php
define('DATAURL','http://magpiedev.com/data.php');
$data_source_url = DATAURL.'?bget=1&'.session_name().'='.session_id();
$basket_details = simplexml_load_file($data_source_url);
?>
 [2008-02-19 17:46 UTC] doc+phpbugs at skynet dot ie
Sorry, I meant to add that the url listed here isn't real but the result should happen with any url which utilises a session on connection.
 [2008-02-24 00:30 UTC] jani@php.net
That's still quite complete script, or do you start sessions automatically? (it's missing session_start(); :)

And as you're obviously calling another script on same server with same session as the current one, you should be using this:

http://php.net/session_write_close

You should put the call to session_write_close(); before the curl/simplexml calls.
 [2008-02-24 00:31 UTC] jani@php.net
s/complete/incomplete/ :)
 [2008-02-25 17:58 UTC] doc+phpbugs at skynet dot ie
hello, yes, sessions were being started automatically, and thanks, that solved the problem. I didn't realise you could get them locking like that.

Thanks, closing the bug.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 30 00:01:30 2024 UTC