We have a route that pulls JSON data from same server that is hosting the front-end but on a different sub domain. The call always fails with a connection refused error. However, pulling the data by calling the resource route directly works without issue.
Here is the failing code.
$client = new Client();
$response = $client->get("http://api.xxxxx.xx./invoice/".$accountNumber."/".$invoiceNumber."/".$date);
$invoicecontent = json_decode($response->getBody()->getContents());
The above always fails with this error:
ConnectException in CurlFactory.php line 186:
cURL error 7: Failed to connect to api.xxx.xx port 80: Connection refused (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
However, opening the failing page in the browser works perfectly.
Server enviroment:
Windows 10
XAMPP
PHP 7
Any suggestions would be appreciated.
Related
I try to scrape a websites HTML code with a guzzle http-request. In the browser (chrome) everything works fine, but when I try to execute the PHP script with the console (windows) I get the following error:
GuzzleHttp\Exception\ConnectException: Connection refused for URI https://example.com
$httpClient = new \GuzzleHttp\Client();
$response = $httpClient->get("https://example.com");
$htmlString = (string) $response->getBody();
I downloaded "php-7.4.23-nts-Win32-vc15-x64.zip" and extracted it I
navigated to the folder where I extracted php I ran
php c:\myproject\index.php
I am unable to call web-services that are deployed on another server
When I test the service using curl from command line
curl https://my_app_domain.com/testing_url
I get this error:
curl: (35) Unknown SSL protocol error in connection to my_app_domain.com:443
That server has 2 apps deployed there, they both talk to each other and it's working all fine, issue is when I call services from another server (another app).
Try to setup the SSL version with your Curl option
curl_setopt($curl, CURLOPT_SSLVERSION,3);
I'm using whatsapp api with laravel 5.2
https://github.com/mgp25/Chat-API
And i got this error when i trying to send new message
socket_write(): unable to write to socket [10053]: An established connection was aborted by the software in your host machine.
Send Controller
$massage = "Thanks for subscribe";
Whatsapi::send($massage, function ($send) {
$user = User::Find(1);
$send->to($user->phone);
}
While following this tutorial
I was getting the same error in phperror.log which I have configured in my php.ini. Initially I thought it was due to some firewall issue, but it wasn't.
The problem was, I was running the client first and then the server. Client was probably not able to make a connection with the server when it ran for the first time.
So I resolved it by running the server first and then the client, which can now make a successful web socket connection.
EDIT : This error also comes up when we simply reload the client page without properly terminating the previous connection.
I'm trying to integrate a PHP portal with a CRM(microsoft dynamics .NET) system using SOAP.
This is part of my code:
$client = new SoapClient("http://XX.XXX.X.XX:5050/host.svc?wsdl");
This line returns 2 errors
Warninig: Message: SoapClient::SoapClient(http://80.248.5.35:5050/host.svc?wsdl): failed to open stream: Connection refused
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://XX.XXX.X.XX:5050/host.svc?wsdl' : failed to load external entity
Opening the link in the browser works and running this code in my local machine(localhost) works also.
i've tried file_get_contents("http://XX.XXX.X.XX:5050/host.svc?wsdl"); but this returns a warning message
Message: file_get_contents(http://80.248.5.35:5050/host.svc?wsdl): failed to open stream: Connection refused
i've tried so many solutions from stackoverflow.
If anyone could help me with this or shed more light on the situation cause this is my first attempt at something like this. Thanks
I found out the problem.
My webserver was denying me from making outgoing connection through any port rather than the default port. i fixed it by changing the web service to the default port on the ISS
I've been frustrated by this "failed to open stream" error too, but from the point of view of trying to connect to a web service from the web.
However, the issue is the same underneath: your web server needs to be able to reach the web service from itself.
My solution if you are using a Windows Server: add an entry to your windows host file to allow loopback on the server for the external domain you're using for the web service.
So, open your "hosts" file, which is usually in somewhere like C:\Windows\System32\drivers\etc. Then add a line like:
<machine LAN IP like 192.168.1.1 or 127.0.0.1> <domain.ofwebsevice.com>
I just follow same code from Facebook SDK example.
If FB App point to my local desktop, it will get Facebook uid and user basic information (ex email) if APP get permission from OAUTH request.
But when I upload files to server, executing $facebook->api('/me');
Fatal error: Uncaught CurlException: 28: connect() timed out! thrown in
/xxx/src/facebook.php on line 622
I still can't figure out why. It comes from CURL or SSL setting?
My remote server support SSL and CURL is enabled. My local is only CURL but no SSL support.
I think my Facebook SDK is old version, only facebook.php without base_facebook.php.
I try to use new version but can't run any program because crt error.
You get this error because your host cannot access the Facebook API. It might have an old version of Open SSL, can you check the current version on the server?
Try to connect using SSL from your local setup as well as it might be easier to debug on your local machine.
Also, see about that crt (CRC?) error and try to fix that first (don't shave too many Yak's though).