vector icon indicating copy to clipboard operation
vector copied to clipboard

feat(nats): Added feature flag for websockets in async-nats

Open gedemagt opened this issue 1 month ago • 4 comments

Summary

This PR adds websockets to async-nats.

Vector configuration

sources:
  nats-input:
    type: nats
    subject: input
    url: ws://localhost:8080
    connection_name: test

sinks:
  nats:
    type: nats
    inputs:
      - nats-input
    subject: test
    url: ws://localhost:8080
    encoding:
      codec: json

How did you test this PR?

Running a nats server with the following docker-compose.yml

configs:
  nats-server.conf:
    content: |
      server_name: sitehub
      websocket {
          port: 8080
          no_tls: true
      }

services:
  nats:
    image: nats:2.11.8
    ports:
      - "8080:8080"
      - "4222:4222"
    configs:
      - nats-server.conf
    command:
      - "--config=/nats-server.conf"

The Vector config specified in the previous section was used, and then the data feed through was tested with a few nats commands:

nats sub test

nats pub input Hello

This results in the following on the subscription

20:25:04 Subscribing on test
[#1] Received on "test"
{"message":"Hello","source_type":"nats","subject":"input","timestamp":"2025-11-21T19:25:33.011930438Z"}

Change Type

  • [ ] Bug fix
  • [x] New feature
  • [ ] Non-functional (chore, refactoring, docs)
  • [ ] Performance

Is this a breaking change?

  • [ ] Yes
  • [x] No

Does this PR include user facing changes?

  • [ ] Yes. Please add a changelog fragment based on our guidelines.
  • [x] No. A maintainer will apply the no-changelog label to this PR.

References

  • Closes: #24285

Notes

  • Please read our Vector contributor resources.
  • Do not hesitate to use @vectordotdev/vector to reach out to us regarding this PR.
  • Some CI checks run only after we manually approve them.
    • We recommend adding a pre-push hook, please see this template.
    • Alternatively, we recommend running the following locally before pushing to the remote branch:
      • make fmt
      • make check-clippy (if there are failures it's possible some of them can be fixed with make clippy-fix)
      • make test
  • After a review is requested, please avoid force pushes to help us review incrementally.
    • Feel free to push as many commits as you want. They will be squashed into one before merging.
    • For example, you can run git merge origin master and git push.
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please run make build-licenses to regenerate the license inventory and commit the changes (if any). More details here.

gedemagt avatar Nov 21 '25 13:11 gedemagt

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

github-actions[bot] avatar Nov 21 '25 13:11 github-actions[bot]

I have read the CLA Document and I hereby sign the CLA

gedemagt avatar Nov 21 '25 13:11 gedemagt

recheck

thomasqueirozb avatar Nov 21 '25 20:11 thomasqueirozb

Do I need to do more work on this to get a review?

gedemagt avatar Dec 02 '25 08:12 gedemagt

Hi @gedemagt, can you add a changelog? This is a nice addition.

Also, do you know what the behavior was previously? Did it panic/crash, fail with some (useful) error message or silently fail?

thomasqueirozb avatar Dec 10 '25 16:12 thomasqueirozb