1
votes

I've got an angular app created with Yeoman that is working well in dev, on port 9000.

I've got a server-side node.js app running on port 3000.

I've installed socket.io on the NodeJS application.

Most of the JS in my angular app is in the app directory, but the socket.io.js is served up via node:

<script src="components/angular/angular.js"></script>
<script src="components/angular-resource/angular-resource.js"></script>
<script src="components/angular-cookies/angular-cookies.js"></script>
<script src="components/angular-sanitize/angular-sanitize.js"></script>
<script src="http://localhost:3000/socket.io/socket.io.js"></script>

This feels kind of wrong to me. Also, when I load socket.io and call connect() on the client side, it is trying to connect to localhost:9000, instead of localhost:3000

Is there a way to reconcile these two worlds? Do I need to serve my angular application from within node.js? I'm reluctant to lose live reloading.

1

1 Answers

2
votes

You can have it all!

In your connect call make sure you connect to the websocket server, i.e.

var socket = io.connect('http://localhost:3000');

Loading the script from the socket server is fine. There is nothing wrong with this.