I am using the AWS PHP SDK to interface with a CloudSearch instance and it appears to work fine on my production and staging servers, but I am continually getting Guzzle/cURL errors in my local environment (using VVV of local WordPress development in vagrant).
For each request I see this error
Uncaught exception 'Guzzle\Http\Exception\CurlException' with message
'[curl] 6: Could not resolve host: search-localalumnispacesv2-ytnhdpo4wvr56v66sfdkwmk5lu.us-east-1.cloudsearch.amazonaws.com
When I error log $e->getMessage(), I can see the url it is using to call the AWS APIs and testing that url via the browser directly, through HTTP test apps or with cURL directly in command line (on my host machine), I'm able to get a response without any problem. This leads me to believe that the actual request is fine and the host is valid.
I can reproduce the problem when I ssh into the virtual vagrant box and do a cURL command for the url, leading me to believe that the issue is isolated to requests made from within my vagrant box.
Any ideas for what might be causing it not to resolve within vagrant?
Related
I am working on a React web app with npm for the first time. I'm done with the development and now putting the built package on the web server (bluehost).
All is working well on my Mac: the web app allows getting data from mySQL via php, and posting back to the database.
But when I try the same app (on the same URL, same server, script, same everything...) on my Windows machine, I get an error on the first http request used for authentication.
OPTION http://example.com/script.php net::ERR_CONNECTION_REFUSED
First I thought this was a browser issue.
But I don't get the error on Chrome on my mac but do on Chrome on my Windows, as well as FireFox.
Again, I do not get this error when I test the app on my mac.
Could anybody please give me some direction to solve this?
Thank you!
I have a web service application that works fine in my local. I have even installed ngrok and I'm able to call it on the public web. But as I put my code on our production server I keep getting the 'Couldn't resolve host' error. I'm using different APIs in my service and intermittently I get this error. (I use apache in my local and nginx on prod)
For example I work with googleapis.com and sometimes it works and sometimes it doesn't on the server. The exact same code works just fine on my local.
It's worth mentioning that I've had this application for few months on this server and it's only this past few days that I've started to get these type of errors.
BTW I've noticed that the Curl version in my local and production and their settings are different but I don't know if that could be the source of the problem because it was working just fine.
I would appreciate any kind of guidance.
I've created an application in php that sends texts out to people using the twilio api. It works perfectly in XAMPP but the php code doesn't run in Azure. Everytime I call it I get an error message saying "Failed to load resource: the server responded with a status of 500 (Internal Server Error)".
Is there a way I can solve this problem without having to create my own virtual server?
Usually, when we get 500 response, it means we get some errors on server scripts. And we can set the display_errors=On in PHP runtime on our Azure Web Apps for easy troubleshooting. Refer to https://azure.microsoft.com/en-in/documentation/articles/web-sites-php-configure/#how-to-change-the-built-in-php-configurations for details.
And you may check whether your application on Azure Web Apps has successfully installed the twilio lib. You can leverage composer to configure the sdk in composer.json, then when you deploy your application to Azure via Git, Azure service will install the dependencies in composer.json file automatically during the deployment task.
You can leverage require 'vendor/autoload.php' to load all the dependencies.
At the first time during the test, I got the following error:
Fatal error: Uncaught exception Services_Twilio_TinyHttpException with message SSL certificate problem...
So it may be the issue on your side too, you can add the certificate in PHP on Azure Web Apps, please refer to https://blogs.msdn.microsoft.com/azureossds/2015/06/12/verify-peer-certificate-from-php-curl-for-azure-apps/ for detailed steps.
Otherwise, you can simply edit TinyHttp.php in twilio lib:
add CURLOPT_SSL_VERIFYPEER => FALSE, at $opts array.
Refer to Twilio PHP - SSL certificate: self signed certificate in certificate chain for the same issue.
They have many possibles:
Your Azure running PHP in ISS Server, then you need convert your .htaccess file to web.config, simple, just go to website in IIS and on import your .htaccess file, IIS will convert your .htaccess in web.config.
Permissions on folder you are running.
PHP versions, check your PHP version on xampp and compare to PHP version on Azure. Your code can be compatible in your PHP Xampp but not in PHP Azure.
Extensions PHP, it is possible that your xampp has extensions for PHP enable that your Azure not are enable, like file_info, etc...
I'm a newbie in aws and have created an ec2 instance on ubuntu server with php, mysql and apache installed where I have hosted couple of html files along with other scripting php files. The website is working fine. I have created a webservice which has to be consumed in different clients. The purpose of this webservice is to insert some values in a remote db table.
a) www.abc.com/client/add.php returns success and I cud see the values getting updated in the db table
The above webservice is working fine on a test server but when I had uploaded the same set of files on aws ec2, the webservice is giving me an error.
b) www.abc.com/client/add.php returns failure. I have checked the db configuration file, connection strings for remote host is correct.
I am also facing similar issue in integrating sms api to push sms to consumers cell. On Test server, my code is working fine and sms are pushed but same piece of code is not working on aws ec2.
I suspect, it is related to the rules in ec2 security group because of which it cannot connect to the remote mysql host and to the sms gateway.
Can any of you help me in assigning the proper rules ?
Currently I have assigned the below privileges for Inbound rules
type HTTP, port 80 for all
type Mysql port 3306 for all
All traffic for all
type SSh, port 22 for all
Do I have to assign any outbound rule as well ?
Firstly thanking #bluto for pointing me to the log files where I was able to see the errors and fix them.
My aws inbound and outbound rules were appropriate.
From the log files, I identified mysql_connect(): Access denied for user.
To fix this I had to explicitly assign the host IP address in allowable host section of the db webserver.
For the second issue wherein my SMS api was not working, I identified the error in log file
PHP Fatal error: Call to undefined method mysqli_stmt::get_result().
To fix this, I came to know that mysqlnd is required to execute Bind_result() & fetch() which was missing in my aws ubuntu server.
http://php.net/manual/en/mysqli-stmt.get-result.php
I had to install mysqlnd by the following command.
apt-get install php5-mysqlnd
Pls remember that installing mysqlnd will break your appcode. For it to work, I added the following line in the end of of php.ini file. The path of php.ini file can be find by output of php.info()
extension=mysqlnd.so
After successful installation, I saw that curl needs to be installed in the server as I was getting an error. I installed it by the below command. Ensure to restart the apache server after the installation
sudo apt-get install php5-curl
References:
Call to undefined method mysqli_stmt::get_result
https://askubuntu.com/questions/386887/install-curl-ubuntu-12-04
I am running a virtual machine on my computer (debian 6.0.2.1) that runs an apache+php+mysql server. On my local machine I have a WAMP stack instaled. On both machines I have CodeIgniter deployed and running a RESTful API.
What I am trying to do is to communicate with my virtual machine from the local machine's application. The virtual machine's application accepts post & get methods for an end-point.
e.g. http:///thumbs/save/ it should return a message. If I test it in the browser for the get method, it runs fine. The problem is when I try to access it from the other application (local machine deploy) with a jquery post/get I get the following:
for chrome as usual: XMLHttpRequest cannot load http:///api/thumbs/save. Origin "http://localhost" is not allowed by Access-Control-Allow-Origin.
and firefox just throws a 200 with status OK but it shows up red and with no response.
A little help would be appreciated. Tell me if you need code examples.
Thanks.
The reason you are seeing that error, Access-Control-Allow-Origin, is to prevent a security issue known as XSS (Cross Site Scripting). Your one domain is localhost, and the other is API.
Take a look at this question/answer for some ways around it. No code examples, so not sure what methods/access types you are using: Access-Control-Allow-Origin error sending a jQuery Post to Google API's