0

Tried to solve this problem myself, but failed.

The idea is that i'm trying to run "MjmChat" extension of Yii (chat extension on nodejs). Actually, it works, but it works only on 8000 port. If i set any port different from 8000, socket.io does not serve its js.

For tests, i just cut out all the nodejs code, so it look like

var express = require('express');

var app = express(), 
    server = require('http').createServer(app),
    io = require('socket.io').listen(server);

server.listen(8000);

It is located in the web root of my test-server (gs-test.ru) So when i run

root@gs-test:/var/www/fortis/data/www/gs-test.ru# node app.js

http://gs-test.ru:8000/socket.io/socket.io.js serves js well.

BUT! If i try to change 8000 to 8001, 9000, 9999, whatever (of course, with stopping current app.js and then restarting it) - it does not work! Just can not load socket.io.js.

Every port i tried was free (tested with #netstat -ntp), so my only idea is that the problem is with apache/nginx or smth in webserver configuration (I run debian squeeze on fastvps.ru VDS).

Thanks in advance!

Fortis
  • 13
  • 4

1 Answers1

0

Are you violating same origin policy? Scheme, host, and port must match or the browser will not connect. Many like haproxy for this. It sounds like you're starting the app on your desired port just fine but can't connect via browser. Is there an express app running here too?

Plywood
  • 891
  • 1
  • 7
  • 16
  • actually i'm not very good at server configuring, i'm just copying some examples and change them for my tasks... So what do you mean by running express app? Do i need to run not only "node app.js" but some more services? – Fortis Oct 17 '13 at 07:10
  • Are you testing this in the browser? I believe this may help you: http://stackoverflow.com/a/12039741/2005565 – Plywood Oct 17 '13 at 19:03
  • tried to do so, but i get warning "Socket.IO's `listen()` method expects an `http.Server` instance as its first parameter", and though socket.io starts, browser displays "Cannot GET /socket.io/socket.io.js" – Fortis Oct 18 '13 at 06:31