octoblu / meshblu

Meshblu is a cross-protocol IoT machine-to-machine messaging system.
https://meshblu.readme.io/
MIT License
816 stars 181 forks source link

Issue: Websocket Polling not working #74

Closed fokusferit closed 10 years ago

fokusferit commented 10 years ago

For testing a demo, we had to switch from basic 'websocket' subscription to 'polling' as the preferred subscription method.

This caused an issue on meshblu, with the following error:

Presence offline for socket id:  CTJG-mlNjENh1elJAAAB
getDevice socket info: CTJG-mlNjENh1elJAAAB undefined
sendMessage() from undefined { payload: { online: false }, devices: '*' }
devices: *
message: {"payload":{"online":false},"devices":"*"}

http.js:691
    throw new Error('Can\'t set headers after they are sent.');
          ^
Error: Can't set headers after they are sent.
    at ServerResponse.OutgoingMessage.setHeader (http.js:691:11)
    at Router.find (/home/user/meshblu/meshblu/node_modules/restify/lib/router.js:493:17)
    at Server._route (/home/user/meshblu/meshblu/node_modules/restify/lib/server.js:610:17)
    at routeAndRun (/home/user/meshblu/meshblu/node_modules/restify/lib/server.js:569:14)
    at /home/user/meshblu/meshblu/node_modules/restify/lib/server.js:585:17
    at next (/home/user/meshblu/meshblu/node_modules/restify/lib/server.js:749:22)
    at f (/home/user/meshblu/meshblu/node_modules/restify/node_modules/once/once.js:16:25)
    at Server._sanitizePath (/home/user/meshblu/meshblu/node_modules/restify/lib/plugins/pre/pre_path.js:37:9)
    at next (/home/user/meshblu/meshblu/node_modules/restify/lib/server.js:730:30)
    at f (/home/user/meshblu/meshblu/node_modules/restify/node_modules/once/once.js:16:25)

Maybe, it's necessary to create an additional handler to handle polling requests via websockets, isn't it?

Cheers

chrismatthieu commented 10 years ago

WebSockets don't use headers and we don't currently support long-polling. Feel free to send us a pull request when you get this updated. Thanks.