http://domain.local/socket.io/1/?t=1363363318728 m

2019-08-25 15:17发布

问题:

I have a CodeIgniter driven website. I want to implement a web chat based on NodeJS+Socket.IO.

I have the chat working on other local domain at the main folder, but when I moved it to the CodeIgniter it stopped working. I guess it is because I changed the folders relation to suit CodeIgniter's structure.

I have placed the node_modules at root folder.
The server.js is inside the node_modules folder.
The client javascript chat.js is placed in folder public/js
My view file is in application/views/chat.php
This view is accessible at location domain.local/conversation/room

When I open the page in the console I see:

http://domain.local/socket.io/1/?t=1363363318728 moved permanently

回答1:

I've found what's wrong.

The connection script was pointing to
var socket = io.connect('http://domain.local/node:8080')
and it should be to the root domain
var socket = io.connect('http://domain.local:8080')