Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Could not connect to host #74

Open
gabohm opened this issue May 3, 2017 · 8 comments
Open

Could not connect to host #74

gabohm opened this issue May 3, 2017 · 8 comments

Comments

@gabohm
Copy link

gabohm commented May 3, 2017

Hi, sometimes that I try to connect to Salesforce I have this error:
Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in /Force/soapclient/SforceBaseClient.php:168 Stack trace: #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'https://login.s...', '', 1, 0) #1 Force/soapclient/SforceBaseClient.php(168): SoapClient->__call('login', Array) #2 Force/soapclient/SforceBaseClient.php(168): SoapClient->login(Array) #3 /home/donahoy/public_html/sincroniza/sincroniza.php(12): SforceBaseClient->login('universe...', '...') #4 {main} thrown in /Force/soapclient/SforceBaseClient.php on line 168

@jeromegv
Copy link

jeromegv commented Oct 9, 2017

Same problem for me, any idea @metadaddy ?

@jeromegv
Copy link

I ended up doing something like that, which fixed it

$mode = array(
  'ssl_method' => SOAP_SSL_METHOD_TLS,
  'encoding'=>'UTF-8',
  'cache_wsdl'    => WSDL_CACHE_NONE,
  'stream_context'=> stream_context_create(
    array(
      'ssl'=> array(
        'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT,
        'ciphers' => 'SHA256',
        'verify_peer'=>false,
        'verify_peer_name'=>false, 
        'allow_self_signed' => true
      )
    )
  )
);

$client->createConnection($partner_wsdl, null,$mode);

@metadaddy
Copy link
Contributor

@jeromegv I left Salesforce about 18 months ago and am no longer working on this. Not sure who owns this now - maybe @ReidCarlberg?

@gabohm
Copy link
Author

gabohm commented Oct 11, 2017

@jeromegv thanks for your answer, I'll try the code.
Where do you get this data?
SOAP_SSL_METHOD_TLS
WSDL_CACHE_NONE
STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT

@fernandoagostini
Copy link

@jeromegv Thanks for the code. Spent a few hours until I stumble upon your answer. All happen after updating PHP version. Had other problems (not SalesForce) because of "verify_peer" settings. Thanks again!

@BuildBuilt
Copy link

@fernandoagostini ..

Hi , right now I am facing problem that PHP is not able to connect to the HOST.
Could you guide me on this ?

Best Regards,

@hatzopoulos
Copy link

hatzopoulos commented May 10, 2018

I am pretty sure the HTTP connection simply failed, it happens. Could be SF, could be the requesting server, could be the network, a simple timeout due to congestion. You will need to detect it, and re-run your request. An example of this is Guzzle's retry-subscriber.

@GreenBattery
Copy link

It's worth pointing out that @jeromegv 's response is very helpful, but it disables TLS security effectively as no certificate verification is done (making it vulnerable to MITM attacks). This may be okay in development environments but worth careful consideration for code that will be used in production.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants