connect node js server to a running php web server - php

I'm developing a realtime chat app using node js, socket io which is embedded unto an php app. So basically, running my php app unto my local machine by...
php -S localhost:8000
and then the node server runs on port 3770 and yet, I was unable to connect to my node server. Tried...
var socket = io.connect('http://localhost:8000/my-php-app/:3770');
Seems, i put the wrong web socket url. Any help, ideas?

Related

Wamp server connection

I have developed an android app that connect mysql database using php. when making https request to scripts php from other computers located on the same local network no problem, but when trying to request the same scripts from my android phone it gives tcp errors.
There is however a far better solution. You can access your host machine with the IP address "10.0.2.2".
This has been designed in this way by the Android team. So your webserver can perfectly run at localhost and from your Android app you can access it via http://10.0.2.2:8080.
What error do you get? If it's a forbidden error then it could be your httpd config file blocking your android. Can you tell from the error whether the problem is in your android application or a network connectivity error?

Is there a way to connect sockets from perl script to a PHP server?

I am new to the concept of web socket connections and this would be of real help to me.
I have XAMPP running on a local machine.
How can i connect via a socket to the APACHE server on this machine ?
I am not getting any leads. Is there a tutorial to set that up ?
Also how do I control what happens when a socket connection is made towards the server side ?
It sounds like you want to connect to a web server on localhost and fetch a document from it. The easiest way to do that is to not worry about interacting with sockets directly and instead use a prepackaged web client library, such as LWP or LWP::Simple.

how to put php and node.js togther

I have test node.js + socket.io with port 8080 yesterday
i found that the frontend page which receive the data and send request must defined as HTML
which mean, i can use a mvc php combine with node.js and socket.io
is there any way to do that?
more if i define the node server as localhost:8080
i cant call the web server by other place, such as localhost
unlike nature websocket, i can use the socket anywhere, and i just need to define the socket address as localhost:8080
anyway to solve out?
Run node on port 8080 run php on port 8081. Use php to run your frontend HTML and JavaScript include the frontend socket.io library and connect to localhost:8080 (the node server)
// client side code
var socket = io.connect('http://localhost:8080');
This is untested, and I don't know if this is what you want, or if it will work.

Open a page available only on the server (backend proxy)

I have a frontend application that need to call a reporting services, opening a new window with a javascript function like this :
window.open('http://somedomain.com:8080/report')
What I wanna do now is, since the tomcat server is on the same machine of the backend application(and on the same machine of the web server - php), avoid to open the 8080 port on the internet.
In simple words, I need a way to connect the tomcat application server(through localhost) and proxy the connection to the frontend without requiring to open the port 8080 of the server to the all world. Is it possible ?
How can it be done ?
To generate html page on the server I use php...
EDIT/UPDATE
The page on the tomcat application server is not static, it has a loading mechanism and need user interaction ...
You could use PHP's cURL functions to get the information you need via PHP (using localhost:8080) and use this as a PHP proxy. Then use Ajax to retrieve the information from the PHP proxy.

PHP Websocket not listening for remote connection

I am trying to write up a realtime chat app using Websockets. I tried to set up a Websockets server using two different PHP implementations. (https://github.com/lemmingzshadow/php-websocket and http://code.google.com/p/php-websocket-server/) I ran the server using xampp shell and both worked fine when I connected from the same computer. However, when I tried to connect using another computer in the same LAN, the server didn't even receive a handshake request.
Is that due to the same-origin policy? Is there a workaround?
I am using xampp 1.7.1 and PHP 5.3.8 if that matters

Categories