Open Melchyore opened 6 years ago
@Melchyore Thanks for posting, we'll take a look as soon as possible.
For help with questions about Sails, click here. If you’re interested in hiring @sailsbot and her minions in Austin, click here.
Was there ever a response or method for not using client side sockets to send HTTP requests but still allowing pub/sub broadcasts etc through client/server?
@Melchyore @MattGarnettWelsh The first argument to sails.sockets.join()
should be either a socket id or req
(never req.socket
):
https://sailsjs.com/documentation/reference/web-sockets/sails-sockets/join
But always use req
unless you reaaaaaallllly know what you're doing. (socket ids are node-process-specific and best avoided-- use rooms instead)
@Melchyore re:
... logs a Socket Object so, why does req.socket is not a socket?
This is a confusing thing, unfortunately -- req.socket
is a TCP socket instance for HTTP requests and a Socket.io socket for virtual socket requests. (That's actually why we changed this back in 2016-- we used to support both, when possible, but that was even more confusing, because developers kept passing in TCP sockets on accident)
@mikermcneil Hi Mike, thanks for the response.
I guess my queries stem from the fact I'm not using sails sockets (specifically angular-sails) anymore (https://www.npmjs.com/package/angular-sails) as I noticed sails doesn't support WSS. Or am I wrong here?
In light of not supporting WSS I've moved to straight angular-http to handle client side http requests for my services. I'd still like sails-sockets to handle my live events though.
@MattGarnettWelsh Seems like we're not quite on the same page: Sails supports secure WebSockets -- see https://ration.io and the Platzi course for an example deployment to Heroku that uses wss://
@mikermcneil Hi Mike, funnily enough I did actually do your course a while back! We now use the sails implementation of secure websockets - thanks a lot.
Sails version: 1.0.1 Node version: 8.8.1 NPM version: 5.4.2 DB adapter name: sails-postgre DB adapter version: 1.0.0 Operating system: Windows 7 Ultimate x64
Hello,
I have a basic HTML page containing a basic script:
and then, in the server, after authentication step, I try to join a WS room, but it fails:
and logs :
warn: Attempted to call
sailsSockets.join, but the first argument was not a socket.
... logs a Socket Object so, why does
req.socket
is not a socket?I don't want to use
post
andget
methods of socket.io, all what I want is emitting events from server to client.