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.

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

报告相同问题?

悬赏问题

  • ¥15 电脑开机过商标后就直接这样,求解各位
  • ¥15 mysql , 用自己创建的本地主机和用户名 登录不上
  • ¥15 关于#web项目#的问题,请各位专家解答!
  • ¥15 vmtools环境不正常
  • ¥15 请问如何在Ubuntu系统中安装使用microsoft R open?
  • ¥15 jupyter notebook
  • ¥30 informer时间序列预测
  • ¥20 SSR引物多态性分析
  • ¥15 大漠插件在Win11易语言注册调用和免注册灵异事件,VS上注册调用完全没问题
  • ¥15 Addressable缓存机制做热更新的问题