angular-socket-io
angular-socket-io copied to clipboard
socket.io 404 (Not Found)
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:
- Downloaded angular-socket-io and socket.io-client via bower
- Added angular-socket-io and socket.io-client libraries in my
index.html
page - Added
btford.socket-io
in myapp.module
atapp.js
file - Added following code to my
Socket.js
file which is located in same folder thanapp.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')
i have the same issue. http://localhost/socket.io/?EIO=3&transport=polling&t=MQaU_0i 404 (Not Found)
@DevChrisDev Did you solve this problem?I am getting same error...