{"id":20365891,"url":"https://github.com/cycoresystems/meteor-nats","last_synced_at":"2025-06-20T10:35:15.173Z","repository":{"id":148364055,"uuid":"48013383","full_name":"CyCoreSystems/meteor-nats","owner":"CyCoreSystems","description":"Meteor NATS client","archived":false,"fork":false,"pushed_at":"2015-12-31T17:35:18.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-25T15:03:42.034Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CyCoreSystems.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-15T02:02:22.000Z","updated_at":"2015-12-15T02:05:19.000Z","dependencies_parsed_at":"2023-04-17T10:54:19.272Z","dependency_job_id":null,"html_url":"https://github.com/CyCoreSystems/meteor-nats","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyCoreSystems%2Fmeteor-nats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyCoreSystems%2Fmeteor-nats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyCoreSystems%2Fmeteor-nats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyCoreSystems%2Fmeteor-nats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CyCoreSystems","download_url":"https://codeload.github.com/CyCoreSystems/meteor-nats/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241907631,"owners_count":20040502,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T00:20:58.654Z","updated_at":"2025-03-04T19:26:26.381Z","avatar_url":"https://github.com/CyCoreSystems.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Meteor-NATS\n\n[NATS](http://nats.io) is a pub-sub messaging system.  This package wraps the [NodeJS](http://nodejs.org) \n[nats](http://github.com/nats-io/node-nats) client for use with [Meteor](http://meteor.com).\n\n## Caveats\n\n### TLS\n`node-nats` does not support NodeJS v0.10.x, so until Meteor gets support for modern versions\nof NodeJS, we have to do some kludge-work to get this going.\n\nEven then, **THIS VERSION WILL NOT WORK WITH TLS** due to incompatibilities, despite the fact\nthat the code is present.  Because this package is exported only on the server side, you can\nstill use TLS between your Meteor client and server.  It is only the NATS client which cannot\nuse TLS.\n\nFollow meteor/meteor#5124 to see when this can be fixed.  Then we can use the Npm package without\nthe kludgy direct modification of the upstream client.\n\n### Hot code reload\n\nDuring development, the hot code reload on the server will not properly close your client\nconnections or subscriptions.  As such, you will probably want to add a `SIGTERM` listener\nfor each client:\n\n```javascript\nvar nc = connectNats();\nnc.once('connect',Meteor.bindEnvironment(function() {\n   process.once('SIGTERM',function() {\n      return nc \u0026\u0026 nc.close \u0026\u0026 nc.close();\n   })\n}));\n```\n\n## Basic Usage\n\nAdd the package to your Meteor project with:\n```sh\nmeteor add cycore:nats\n```\n\nThe `nats` global is made available for use by the Meteor server, but in general, you\nshould not interact with it directly.  Instead, use the wrapper `natsConnect()` to obtain\na wrapped copy of the nats client connection.  The documentation on for the Node client\nshould generally be correct for everything else, once you have the wrapped client connection.\n\n```javascript\nvar nc = natsConnect() // use all default values; connect to localhost:4222 as the NATS server\n// or\nvar nc = natsConnect({\n   // This connectionOptions object is entirely optional; null may take its place, as can\n   // any of its properties be omitted.\n   servers: ['nats://server1.tld:4222','nats://server2.example.com:4222'], // may be an array of strings or a simple string\n   tls: true, // true, false, or an object of tlsOptions; defaults to false\n      // tlsOptions: {\n      //   rejectUnauthorized: true, // default: true\n      //   ca: [ fs.readFileSync('ca.pem') ],\n      //   key: fs.readFileSync('client.key'),\n      //   cert: fs.readFileSync('client.cert')\n      // }\n   yieldTime: 10, // maximum processing time chunk before yielding to other transactions\n   user: 'joeTheMeteor', // authentication username\n   pass: 'joeHasAGreatPassword-Meteor', // authentication password\n   reconnect: true, // Whether to reconnect on loss of connection\n   // many more options; see node-nats code\n});\n\n// Simple publisher\nnc.publish('mysubject', 'My Message!');\n\n// Simple subscriber\nvar sid = nc.subscribe('another:subject', function(msg) {\n   console.log(\"Received a message: \" + msg);\n});\nMeteor.setTimeout(function() {\n   nats.unsubscribe(sid);\n}, 1000);\n\n// Request stream\nvar sid = nc.request('myReq:4329', function(resp) {\n   console.log(\"Got a response in msg stream: \" + resp);\n});\n\n// Request with automatic unsubscribe\nnc.request('help', null /* queue Id */, {max: 1}, function(resp) {\n   console.log('Got a response for the helpReq: ' + resp);\n});\n\n// Reply handler\nnc.subscribe('help', function(req, replyTo) {\n   nc.publish(replyTo, 'Here is some food.');\n});\n\n// Close the client connection\nnc.close();\n```\n\nSee the [node-nats](http://github.com/nats-io/node-nats) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcycoresystems%2Fmeteor-nats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcycoresystems%2Fmeteor-nats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcycoresystems%2Fmeteor-nats/lists"}