View our GitHub

Please visit sails-docs on GitHub to view documentation on your mobile device.

Edit Page


A flag indicating whether or not this request (req) originated from a connection.




if (req.isSocket){
  // You're a socket.  Do cool socket stuff.
else {
  // Just another HTTP request.


  • Useful for allowing HTTP requests to skip calls to pubsub or WebSocket-centric methods like subscribe() or watch() that depend on an actual request. This allows you to reuse backend code, using it for both WebSocket and HTTP clients.
  • As you might expect, req.isSocket doesn't need to be checked before running methods which publish to other connected sockets. Those methods don't depend on the request, so they work either way.

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails-docs repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.


We wrote a book!

Get early access to the book
with promotion code: mcneildoc

Get the Book