I have made a chat with SocketIO
who is working well on local, but i'm trying to deploy it on my Apache
server.
I'm using Php + NodeJs, not only Node
I had ERR_CONNECTION_REFUSED
error but solved it by opening the good port, Listen 8000
in my ports.conf
My server.js
look like this
var io = require('socket.io').listen(8000);
// Socket IO usage
My client.js
is
var socket = io.connect('http://[MY SERVER IP]:8000');
// Other client code
I use localhost
in local but I changed by my server ip.
But I still have this error
XMLHttpRequest cannot load http://[MY_SERVER_IP]:8000/socket.io/?EIO=3&transport=polling&t=1455101301883-60. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'MY DOMAIN' is therefore not allowed access. The response had HTTP status code 404.
I really don't know what to do, this is the first I try to deploy a Nodejs + php app. I had read some Stackoverflow questions to try to fix it, but i really don't know how...
I don't knwo if this is due to my Apache
conf or I must change some NodeJS
or SocketIO
conf
Thanks for your help.
I found the problem.
Do not open the NodeJS server port on Apache config. It will make some conflicts and will prevent your Node server to work.
Just change the localhost
by your server IP and it will work fine.