btford/angular-socket-io

socket.io 404 (Not Found)

Opened this issue · 4 comments

Hey,

I'm trying to use angular-socket-io in my project that uses grunt serve command to run the Gruntfile.js. Here's what I have done:

  1. Downloaded angular-socket-io and socket.io-client via bower
  2. Added angular-socket-io and socket.io-client libraries in my index.html page
  3. Added btford.socket-io in my app.module at app.js file
  4. Added following code to my Socket.js file which is located in same folder than app.js:
    app.factory('Socket', function (socketFactory) { return socketFactory(); });

Yet I get following error:

GET http://127.0.0.1:9000/socket.io/?EIO=3&transport=polling&t=1448710127650-0 404 (Not Found)

Problem is very obvious. It simply can't find socket.io library. I have installed socket.io via npm. Is it somehow possible to tell angular-socket-io module the location of socket.io that was downloaded via npm?

I experienced a similar problem when trying to integrate socket.io by itself (without btford.socket-io). In my index.html I changed the file path from:

<script type="text/javascript" src="lib/socket.io/lib/socket.js"></script>

to

<script type="text/javascript" src="/socket.io/socket.io.js"></script>

As the documentation suggests. I haven't integrated btford.socket-io into my project just yet so this may not answer your problem because the included javascript file is different from the ones downloaded via NPM.

Here is a possible answer:
http://howtodevelop.eu/question/reactjs-node-js-socket-io-wont-work-connect-in-reactjs-app,115692#

i.e on your server.js side:
server.listen(port)
instead of
app.listen(port)
!

Also you may need on your client.js side:
const io = require('socket.io-client')

@DevChrisDev Did you solve this problem?I am getting same error...