douqi0090 2016-02-10 10:55
浏览 266
已采纳

Apache + socketIO失败

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.

  • 写回答

1条回答 默认 最新

  • dongxiansi0158 2016-02-15 22:56
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 vb net 使用 sendMessage 如何输入鼠标坐标
  • ¥200 求能开发抖音自动回复卡片的软件
  • ¥15 关于freesurfer使用freeview可视化的问题
  • ¥100 谁能在荣耀自带系统MagicOS版本下,隐藏手机桌面图标?
  • ¥15 求SC-LIWC词典!
  • ¥20 有关esp8266连接阿里云
  • ¥15 C# 调用Bartender打印机打印
  • ¥15 我这个代码哪里有问题 acm 平台上显示错误 90%,我自己运行好像没什么问题
  • ¥50 C#编程中使用printDocument类实现文字排版打印问题
  • ¥15 找会编程的帅哥美女 可以用MATLAB里面的simulink编程,用Keil5编也可以。