Best way to check if your VM is running - php

Browser
VM ip = 172.16.67.137
I goto : http://172.16.67.137:1234/vse/accounts.count on my local brower
I got this response
Object
data:Object
account_count:20
message:"Success"
status:200
Terminal
But how comes when I tried ping that URL
ping http://172.16.67.137:1234
ping http://172.16.67.137
All of them return me
ping: cannot resolve http://172.16.67.137:1234/vse/accounts.count: Unknown host
Did I do something wrong or missing any steps ?
I just want to check if my VMs is running before do any other action, otherwise, throw some errors.
Hope someone can shed some lights on this ...

Ping only works with url's not uri's or ports.
When I say URL I mean with out http://
You would have to do this:
ping 172.16.67.137
Ping does not work with ports
You could use telnet to check it.
telnet 127.0.0.1 8080

From the terminal run curl to get the response
curl http://172.16.67.137:1234/vse/accounts.count

Related

XAMPP can connect via localhost:8080 but not via IP address / 127.0.0.1

I'm trying to get my localhost XAMPP to broadcast over my IP address. localhost works fine but no luck getting it through to my IP.
I have HTTP TCP Port Forwarding on my router set to 80-8080.
How can I do this ? Any ideas?
I found some people suffering with the same problem. Some of them solved it by simply running the following command at windows CMD ( Be sure to run it as administrator ).
netsh http add iplisten 127.0.0.1
Good luck and keep me informed if it didn't work for you.
Figured it out... the HTTP Port Forward IP had to be the same IP as my server (connected device). = )

Curl Error Hostname Not Found in DNS Cache

I have a website (www.example.com | 123.456.789), in that machine i only have 1 web app running. i am trying to use php file_get_content() to a file which in my own server (located on some file like /var/www/my_site/public_html).
The PHP code i am referring is:
$url = 'http://example.com/282-home_default/short-wallet-tan.jpg';
var_dump($url);
$json = #file_get_contents($url);
var_dump($json);
die();
However it always returns error. When i try to do it manually, using CURL
I can confirm that i can CURL other website such as ~$ curl google.com
Can anyone suggest me what to do to resolve this. Thanks
I am using Ubuntu 14.04 LTS to host my webapp.
Some of the solution regarding this question, points out that i should downgrade my version of curl. Did that but still have the same problem.
curl failed to connect to that host's TCP port number 80. You're either not running the http server on port 80, you've made curl try to connect to the wrong server or there's something else in your network that prevents the connect handshake to succeed.

Vagrant server not showing up?

I'm using Vagrant to run a server for me. So I followed this tutorial and when I open up my browser to go check. I get Oops! Google Chrome could not connect to 127.0.0.1. I've also tried localhost and my IP address. Along with a mixture of different ports. The odd part is when I do
curl 'localhost' or curl 'http://127.0.0.1:80' I get
<html><body><h1>It works!</h1>
<p>This is the default web page for this server.</p>
<p>The web server software is running but no content has been added, yet.</p>
</body></html>
I do know that's normal, but I can only get that to show on the command line. Any ideas?
You must set up port forwarding in your Vagrantfile. See https://docs.vagrantup.com/v2/networking/forwarded_ports.html
Example:
Vagrant.configure("2") do |config|
config.vm.network "forwarded_port", guest: 80, host: 8080
end
I've had issues using Vagrant and got some help.
Here is my post and how i made it work:
Setting up Vagrant with PuPHET failure

Php SoapClient timeout (ubuntu)

Am trying to call a soap on the network but i keep getting a timeout(am using Linux Mint), i can tell its a timeout because it takes a while before it comes back with an error... i tried both nusoap and soapclient... the nusoap is throwing "HTTP Error: Unsupported HTTP response status 303 See Other (soapclient->response has contents of the response)"...
I tested the code on windows os and its working...
Below is the code tho:
$client=new SoapClient('http://192.168.1.77:8080/project/Login?wsdl');
$result = $client->__soapCall("checkUserCred", array(
"checkUserCred" => array(
"user" => 'admin',
"password" => "admin" // The ads ID
)
), NULL, NULL);
echo $result->return;
Is there anyway to debug this, am sure its from ubuntu(linx mint) but can't tell what exactly... I tried looking at the apache2 logs file but couldn't find anything...
Your code seems fine, it looks like it's more or less a connection issue. On terminal try to telnet to your server and see what you get...
Something like:
telnet 192.168.1.77 8080
If telnet does respond and allows you to enter something then try to do:
GET /project/Login?wsdl
And hit enter twice. See if you get the WSDL returned properly. You will also need to take a look at your WSDL to see where the endpoint is and do something similar to the endpoint URL to make sure you have connectivity
Alternatively you can do a TCP traceroute as root user to see where it's routing to with
traceroute -T -p 8080 192.168.1.77
Note here: to do a TCP traceroute you have to be root user / sudo command.

PHP can't connect to localhost XMPP server on port 5222

I've set up an ejabberd install locally on my Windows box, where I also have Apache, PHP and MySQL. I've also confirmed that it works great using Digsby, and have kicked the tires a bit by creating some users, sending some messages, etc. All good.
However, PHP can't open a stream using stream_socket_client to port 5222. Even at its simplest level:
stream_socket_client("tcp://localhost:5222", $errno, $errstr, 30, STREAM_CLIENT_CONNECT);
Returns a timeout error. However, again, connecting with an IM client to localhost on port 5222 works fine. (Using stream_socket_client to open a simple connection to localhost on port 80 also works.)
Any ideas? I'm stuck!
selinux needs to be off, or allow apache to talk to xmpp
Many servers don't listen on the loopback device by default, or only listen on ::1 or 127.0.0.1 and have localhost pointing to the other. Check by doing:
% netstat -an | grep 5222
and checking the output for a LISTEN line that shows where your server is listening.
Finally, try using the IP address of your box explicitly as the connection hostname.
Sometimes you just need to peek on the line to see exactly what is going on. Windump(tcpdump) is your friend in these cases.

Categories