attach is not a function
Kikketer opened this issue · 6 comments
Kikketer commented
Pretty simple one to repeat, both the docs and the example cause the same error:
TypeError: sockjs_echo.attach is not a function
Using the example code:
const http = require('http')
const sockjs = require('sockjs')
const node_static = require('node-static')
// 1. Echo sockjs server
const sockjs_opts = {
prefix: '/echo'
}
const sockjs_echo = sockjs.createServer(sockjs_opts)
sockjs_echo.on('connection', function(conn) {
conn.on('data', function(message) {
conn.write(message)
})
})
// 2. Static files server
const static_directory = new node_static.Server(__dirname)
// 3. Usual http stuff
const server = http.createServer()
server.addListener('request', function(req, res) {
static_directory.serve(req, res)
})
server.addListener('upgrade', function(req, res) {
res.end()
})
// Dead here
sockjs_echo.attach(server)
console.log(' [*] Listening on 0.0.0.0:9999')
server.listen(9999, '0.0.0.0')
Has there been a major version update that breaks the documentation?
node -v
v8.12.0
brycekahle commented
There is a big warning on the README in master
:
⚠️️ ATTENTION This is pre-release documentation. The documentation for the latest stable release is at: https://github.com/sockjs/sockjs-node/tree/v0.3.19 ️⚠️
barukasu commented
I have the same issue.
node version= v11.12.0
robertlagrant commented
Wow, that was confusing!
Pines-Cheng commented
same issue,
hanquf1 commented
same issue
youfeed commented
me too