PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > curl fails to connect when not port 80
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
curl fails to connect when not port 80

Réponse
 
LinkBack Outils de la discussion
Vieux 13/03/2008, 18h51   #1
Virgil Hilts
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut curl fails to connect when not port 80

Curl newbie question:

Here is a php script that works fine from the command line with
CURL_OPT_PORT set or not -- either way.

<?php
$fp = fopen( "./results.txt", "w" );
$searchUrl = "http://ethicshare.cs.umn.edu";
$ch = curl_init();
$user_agent = "Mozilla/4.0 pp(compatible; MSIE 5.01; Windows NT 5.0)";
curl_setopt ( $ch, CURLOPT_USERAGENT, $user_agent );
curl_setopt ( $ch, CURLOPT_URL, $searchUrl );
// curl_setopt ( $ch, CURLOPT_PORT, "8080" );
// curl_setopt ( $ch, CURLOPT_POST, 1 );
// curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 ); // return to a var
curl_setopt ( $ch, CURLINFO_HEADER_OUT, 1 );
curl_setopt ( $ch, CURLOPT_FILE, $fp );
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
// curl_setopt ( $ch, CURLOPT_FAILONERROR, 1 ); // fail on errors
// curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, 1 ); // allow redirects
// curl_setopt ( $ch, CURLOPT_TIMEOUT, 15 ); // times out after 15s
$info = curl_getinfo ( $ch );
print ( "curl info = " . print_r ( $info, true ) . "\n\n");

curl_setopt ( $ch, CURLOPT_FILE, $fp );
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
curl_exec ( $ch );
curl_close ( $ch );
fclose ( $fp );
?>

When running this same script through apache however, it works fine without
the port directive. However, I get no results when attempting to connect to
port 8080. Command line curl works fine too. It's only when connecting
through apache that my script fails.

Here are some specifics about my environment:

Apache/2.2.3 (Red Hat)

libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
PHP/5.1.6

Any /suggestions will be *greatly* appreciated!! This is driving me
nuts!

Cheers!


--
Penny for your thoughts now, my boy Bill -- Bruce Springsteen

  Réponse avec citation
Vieux 14/03/2008, 06h58   #2
Chris
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] curl fails to connect when not port 80


> When running this same script through apache however, it works fine without
> the port directive. However, I get no results when attempting to connect to
> port 8080. Command line curl works fine too. It's only when connecting
> through apache that my script fails.
>
> Here are some specifics about my environment:
>
> Apache/2.2.3 (Red Hat)
>
> libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
> PHP/5.1.6
>
> Any /suggestions will be *greatly* appreciated!! This is driving me
> nuts!


Your host could have it blocked in the firewall.
It could be SeLinux getting in the way.

Not sure about other suggestions

Add a verbose call:

curl_setopt($ch, CURLOPT_VERBOSE, true);

and maybe set the error log for it to use:

curl_setopt($ch, CURLOPT_STDERR, '/path/to/file.log');

--
Postgresql & php tutorials
http://www.designmagick.com/
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h36.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09718 seconds with 10 queries