Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attach is not a function #253

Closed
Kikketer opened this issue Feb 14, 2019 · 6 comments
Closed

attach is not a function #253

Kikketer opened this issue Feb 14, 2019 · 6 comments

Comments

@Kikketer
Copy link

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
Copy link
Contributor

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
Copy link

I have the same issue.

node version= v11.12.0

@robertlagrant
Copy link

Wow, that was confusing!

@Pines-Cheng
Copy link

same issue,

@hanquf1
Copy link

hanquf1 commented Feb 15, 2021

same issue

@youfeed
Copy link

youfeed commented May 11, 2022

me too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants