Where is the socket.io client library?

The best way I have found to do this is to use bower. bower install socket.io-client –save and include the following in your app’s HTML: <script src=”https://stackoverflow.com/bower_components/socket.io-client/socket.io.js”></script> That way you can treat the socket.io part of your client the same way you treat any other managed package.

Separating file server and socket.io logic in node.js

In socket.io 0.8, you should attach events using io.sockets.on(‘…’), unless you’re using namespaces, you seem to be missing the sockets part: io.listen(fileserver).sockets.on(‘connection’, handler) It’s probably better to avoid chaining it that way (you might want to use the io object later). The way I’m doing this right now: // sockets.js var socketio = require(‘socket.io’) module.exports.listen … Read more

Can websocket messages arrive out-of-order?

Short answer: No. Long answer: WebSocket runs over TCP, so on that level @EJP ‘s answer applies. WebSocket can be “intercepted” by intermediaries (like WS proxies): those are allowed to reorder WebSocket control frames (i.e. WS pings/pongs), but not message frames when no WebSocket extension is in place. If there is a neogiated extension in … Read more

Can AngularJS auto-update a view if a persistent model (server database) is changed by an external app?

You have a few choices… You could do polling every X milliseconds using $timeout and $http, or if the data you’re using is hooked up to a REST service, you could use $resource instead of $http. You could create a service that uses some Websocket implementation and uses scope.$apply to handle changes that are pushed … Read more

RabbitMQ vs Socket.io?

Update Are there scenarios I need RabbitMQ for web apps where Socket.io doesn’t suffice? Browser users should be able to communicate with eachother through a node.js server. One of the user writes a message and all other users will get it. When you only have these simple requirements then socket.io alone will be enough.. You … Read more

Get connection status on Socket.io client

You can check the socket.connected property: var socket = io.connect(); console.log(‘check 1’, socket.connected); socket.on(‘connect’, function() { console.log(‘check 2′, socket.connected); }); It’s updated dynamically, if the connection is lost it’ll be set to false until the client picks up the connection again. So easy to check for with setInterval or something like that. Another solution would … Read more

WebSocket connection failed: Error during WebSocket handshake: Unexpected response code: 400

Problem solved! I just figured out how to solve the issue, but I would still like to know if this is normal behavior or not. It seems that even though the Websocket connection establishes correctly (indicated by the 101 Switching Protocols request), it still defaults to long-polling. The fix was as simple as adding this … Read more