feat(nats): Added feature flag for websockets in async-nats
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-changeloglabel to this PR.
References
- Closes: #24285
Notes
- Please read our Vector contributor resources.
- Do not hesitate to use
@vectordotdev/vectorto reach out to us regarding this PR. - Some CI checks run only after we manually approve them.
- We recommend adding a
pre-pushhook, please see this template. - Alternatively, we recommend running the following locally before pushing to the remote branch:
make fmtmake check-clippy(if there are failures it's possible some of them can be fixed withmake clippy-fix)make test
- We recommend adding a
- 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 masterandgit push.
- If this PR introduces changes Vector dependencies (modifies
Cargo.lock), please runmake build-licensesto regenerate the license inventory and commit the changes (if any). More details here.
All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.
I have read the CLA Document and I hereby sign the CLA
recheck
Do I need to do more work on this to get a review?
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?