balderdashy / balderdashy/sails
warn: Attempted to call `sailsSockets.join`, but the first argument was not a socket.
- Dominant language
- JavaScript
- Stars
- 22.8k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
**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:
```js
io.socket.on('notifications', notifications => {
console.log(notifications)
})
```
and then, in the server, after authentication step, I try to join a WS room, but it fails:
```js
sails.sockets.join(req.socket, _user.username)
sails.sockets.broadcast(_user.username, 'notifications', { test: 'foo' })
```
and logs :
`warn: Attempted to call `sailsSockets.join`, but the first argument was not a socket.`
```js
console.log(req.socket)
```
... logs a Socket Object so, why does `req.socket` is not a socket?
I don't want to use `post` and `get` methods of socket.io, all what I want is emitting events from server to client.
Contributor guide
Research direction
Start with the server-side authentication flow and the documented Sails sockets join and broadcast entry points; the report's client listener and server snippets show the reproduction. Verify why req.socket is rejected by join, then confirm that the warning is gone and the notifications event reaches the client.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100