gj / fastify-ws

MIT License
55 stars 11 forks source link

Implementation v2.0 #11

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hi, I'm trying to implement your plugin in Fastify 2.0 but it's doesn't work.

fastify.ready(err => {
  if (err) throw err

  console.log('Server started.')

  fastify.ws
    .on('connection', socket => {
      console.log('Client connected.')

      socket.on('message', msg => socket.send(msg)) // Creates an echo server

      socket.on('close', () => console.log('Client disconnected.'))
    })
})

I don't see any error but my client can't connect to my websocket server. Can you help me ?

thank you

gj commented 5 years ago

Hey @xyz-mtl, I was waiting for a couple changes in #10 before shipping it, but I think I will just do that myself now. I'll close this issue when the updated package is published.

gj commented 5 years ago

Published version 1.0.1 to NPM — maintains the same API as 1.0.0 and works with Fastify 1.7.0 - 2.x.

Beware that since 1.0.0 was published, the creator of the uws package has decided to abandon that project, so my advice going forward is to rely on the stable ws package (the default option for fastify-ws).