Complete documentation available at: http://socketcluster.io/
9 July 2015 (v2.2.38)
The store.options
object from the storeController (store.js) now represents the global options object
(containing all settings passed to the master SocketCluster constructor) instead of just the content of storeOptions.
To pass custom options to the store object, you can just add the directly to the master SocketCluster() constructor's options object. E.g:
var socketCluster = new SocketCluster({
workers: 1,
stores: 1,
// ...
myCustomStoreOption: 'bla',
anotherCustomStoreOption: 'foo',
// ...
});
This change was also implemented in sc-redis although we still use a storeOptions property to hold all store-related properties.
So now, inside the storeController, we access the custom storeOptions property from store.options.storeOptions
- This is for backwards compatibility.
If you npm update socketcluster
just make sure that you also npm update sc-redis
- You shouldn't need to change any of your code.
21 June 2015 (v2.2.30)
Added a 'handshake' event on SCServer - This event gets triggered as soon as the SCSocket object is created (before the 'connection' event is triggered). It's a good place to add error-handling logic on the socket or to decorate your SCSocket object with custom properties/plugins. You generally shouldn't start interacting with the SCSocket at this stage - You should do that in the 'connection' event; after handshake has been completed.
14 June 2015 (v2.2.26)
Note that there has been an important fix in iocluster (a submodule of SC). The iocluster module is the one which provides the scServer.global object. There was a major bug which prevented it from storing data properly. This has been fixed in iocluster v2.4.6. To update iocluster on an existing app, you should:
- Navigate to your app's node_modules/socketcluster/ directory
- Then from there, use the command:
rm -R -f ./node_modules/iocluster
npm cache clean
npm install iocluster
- Check ./node_modules/iocluster/package.json to confirm that the version number is '2.4.6'
This is only relevant if you want to use the global object to store volatile data, otherwise it shouldn't affect SC in any way.
6 June 2015 (v2.2.25)
- SocketCluster client - Major refactoring was undertaken - This should make the code much more robust and maintainable.
- SocketCluster client - The 'status' event was removed - Instead, you can now get the status object as the first argument to the 'connect' event handler.
- Authentication is now localStorage/sessionStorage-based (it falls back to storing directly on the instance if localStorage is not supported) instead of cookie-based. This should allow the client authentication feature to work in more places including mobile.
- Authentication is now fully customizable on both the client and server so it can integrate with any existing token-based solution - Details on how to do this will be posted on the website at some point.
4 May 2015 (v2.2.9)
SC2 is now the default version of SocketCluster so to install SC2, it's now:
npm install -g socketcluster
socketcluster create myProject
You can still install SC1, but the package name has changed:
npm install -g sc1
sc1 create myProject
SocketCluster is a fast, highly scalable HTTP + realtime server engine which lets you build multi-process realtime servers that make use of all CPU cores on a machine/instance. It removes the limitations of having to run your Node.js server as a single thread and makes your backend resilient by automatically recovering from worker crashes and aggregating errors into a central log.
Follow the project on Twitter: https://twitter.com/SocketCluster Subscribe for updates: http://socketcluster.launchrock.com/
SocketCluster has been tested for memory leaks. The last full memory profiling was done on SocketCluster v0.9.17 (Node.js v0.10.28) and included checks on load balancer, worker and store processes.
No memory leaks were detected when using the latest Node.js version. Note that leaks were found when using Node.js versions below v0.10.22 - This is probably the Node.js 'Walmart' memory leak - Not a SocketCluster issue.
- Jonathan Gros-Dubois
- Nelson Zheng
- wactbprot (nData)
- epappas (nData)
- Gabriel Muller
There are two ways to install SocketCluster.
Setup the socketcluster command:
npm install -g socketcluster
OR
sudo npm install -g socketcluster
Then
socketcluster create myapp
Once it's installed, go to your new myapp/ directory and launch with:
node server
Access at URL http://localhost:8000/
npm install socketcluster
You will also need to install the client separately which you can get using the following command:
npm install socketcluster-client
The socketcluster-client script is called socketcluster.js (located in the main socketcluster-client directory)
- You should include it in your HTML page using a <script> tag in order to interact with SocketCluster. For more details on how to use socketcluster-client, go to https://github.com/SocketCluster/socketcluster-client
It is recommended that you use Node.js version >=0.10.22 due to memory leaks present in older versions.
In order to run SocketCluster over HTTPS, all you need to do is set the protocol to 'https' and provide your private key and certificate as a start option when you instantiate SocketCluster - Example:
var socketCluster = new SocketCluster({
balancers: 1,
workers: 3,
stores: 3,
port: 8000,
appName: 'myapp',
workerController: 'worker.js',
protocol: 'https',
protocolOptions: {
key: fs.readFileSync(__dirname + '/keys/enc_key.pem', 'utf8'),
cert: fs.readFileSync(__dirname + '/keys/cert.pem', 'utf8'),
passphrase: 'passphase4privkey'
}
});
The protocolOptions option is exactly the same as the one you pass to a standard Node HTTPS server: http://nodejs.org/api/https.html#https_https_createserver_options_requestlistener
Note that encryption/decryption in SocketCluster happens at the LoadBalancer level (SocketCluster launches one or more lightweight load balancers to distribute traffic evenly between your SocketCluster workers). LoadBalancers are responsible for encrypting/decrypting all network traffic. What this means is that your code (which is in the worker layer) will only ever deal with raw HTTP traffic.
- More integration test cases needed
- Unit tests
- Efficiency/speed - faster is better!
- Suggestions?
To contribute; clone this repo, then cd inside it and then run npm install to install all dependencies.
(The MIT License)
Copyright (c) 2013-2015 SocketCluster.io
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.