stomp-js / stomp-websocket

Stomp client for Web browsers and node.js apps
https://stomp-js.github.io/stomp-websocket/
Apache License 2.0
141 stars 36 forks source link

Better support for Node.js #4

Closed kum-deepak closed 7 years ago

kum-deepak commented 7 years ago

Currently the Node.js support seems like bit of an afterthought. Going through the code implies that it is possible to make Node.js support first class. In addition, currently reconnect is not supported which it can with minor changes. Biggest impediment in my opinion is that there are no test cases that cover Node.js use cases. I believe that refactoring browser test cases to additionally work for Node.js is possible.

Please let me know if you are using or planning to use this module in Node.js environment.

Vennik commented 7 years ago

I'm using this in a Node.js environment. Only thing that didn't work for me was a missing dependency on "net": "^1.0.2".

kum-deepak commented 7 years ago

Many thanks! Currently, while the code for using the library in the browser is reasonably ok, the code to support on Node is not very clean. I am aiming to untangle it over few weeks.

Thanks for your support!

kum-deepak commented 7 years ago

Please check branch 3.1.0

After a long time finally figured out ways to make NodeJS first class citizen. Exact same API calls now work in Node as well as is the Browser. Test cases have also been refactored and NodeJS is also able to run all test cases.

While Stomp.overTCP and Stomp.overWS are still supported. In addition just like the browser, connecting using Websocket url is supported as well. Please test this mode. To test replace Stomp.overTCP('localhost', 61613); with Stomp.client("ws://localhost:15674/ws");. You may have to enable Websocket at the server if not done so already.

It now supports auto reconnect. To enable set client.reconnect_delay = 5000; (in milliseconds).

Please ask questions if something does not work as expected. My next task is to overhaul the documentation.

kum-deepak commented 7 years ago

Changes have been moved to master branch. npm package has not yet been released. Please see https://stomp-js.github.io/stomp-websocket/codo/extra/docs-src/Usage.md.html for updated usage instructions.