moscajs / mosca

MQTT broker as a module
mosca.io
3.2k stars 513 forks source link

Set attachHttpServer path as a mandatory param. #679

Open roccomuso opened 6 years ago

roccomuso commented 6 years ago

Hello, Lately I've been working on a project using mosca and the http-proxy-middleware.

If you attach mosca to a server and then you mount a middleware to proxy ws requests on a specific route you'll end up with tons of errors. Because the ws server is mounted on "all the routes". If you're not aware of it, you'll spend hours trying to figure out errors like Invalid frame header.

I'd suggest 2 changes:

  1. Set a default path for the ws entrypoint or set the path param as mandatory for the attachHttpServer(server, path).

  2. Improve the attachHttpServer documentation, with the mandatory path argument.

mcollina commented 6 years ago

I think you should look to use https://github.com/mcollina/aedes, it's more performant, and definitely simpler to integrate.