Comments (14)
I ran the spec and there are errors there too:
1) Client - Reconnect should reconnect to server and replay all subscriptions
Failure/Error: expect(disconnects).to eql(1)
expected: 1
got: 0
(compared using eql?)
# ./spec/client_reconnect_spec.rb:116:in `block (2 levels) in <top (required)>'
2) Client - Reconnect should abort reconnecting if disabled
Failure/Error: expect(nats.last_error).to be_a(Errno::ECONNRESET)
expected nil to be a kind of Errno::ECONNRESET
# ./spec/client_reconnect_spec.rb:179:in `block (2 levels) in <top (required)>'
3) Client - Reconnect should give up reconnecting if no servers available
Failure/Error: expect(disconnects.count).to eql(2)
expected: 2
got: 0
(compared using eql?)
# ./spec/client_reconnect_spec.rb:286:in `block (2 levels) in <top (required)>'
4) Client - Reconnect against a server which is idle during connect should give up reconnecting if no servers available due to timeout errors during connect
Failure/Error: expect(disconnects.count).to eql(2)
expected: 2
got: 0
(compared using eql?)
# ./spec/client_reconnect_spec.rb:353:in `block (3 levels) in <top (required)>'
5) JetStream Pull Subscribe should pull subscribe and fetch messages
Failure/Error: expect(msgs.count).to eql(5)
expected: 5
got: 6
(compared using eql?)
# ./spec/js_spec.rb:296:in `block (3 levels) in <top (required)>'
6) JetStream Pull Subscribe should account pending data
Failure/Error: raise NATS::IO::BadSubject if !subject or subject.empty?
NATS::IO::BadSubject:
NATS::IO::BadSubject
# ./lib/nats/io/client.rb:369:in `publish'
# ./lib/nats/io/jetstream/msg/ack_methods.rb:25:in `ack'
# ./spec/js_spec.rb:510:in `block (5 levels) in <top (required)>'
# ./spec/js_spec.rb:509:in `each'
# ./spec/js_spec.rb:509:in `block (4 levels) in <top (required)>'
# ./spec/js_spec.rb:507:in `times'
# ./spec/js_spec.rb:507:in `block (3 levels) in <top (required)>'
Finished in 3 minutes 4.4 seconds (files took 0.22966 seconds to load)
101 examples, 6 failures, 2 pending
Failed examples:
rspec ./spec/client_reconnect_spec.rb:63 # Client - Reconnect should reconnect to server and replay all subscriptions
rspec ./spec/client_reconnect_spec.rb:130 # Client - Reconnect should abort reconnecting if disabled
rspec ./spec/client_reconnect_spec.rb:230 # Client - Reconnect should give up reconnecting if no servers available
rspec ./spec/client_reconnect_spec.rb:313 # Client - Reconnect against a server which is idle during connect should give up reconnecting if no servers available due to timeout errors during connect
rspec ./spec/js_spec.rb:168 # JetStream Pull Subscribe should pull subscribe and fetch messages
rspec ./spec/js_spec.rb:477 # JetStream Pull Subscribe should account pending data
from nats-pure.rb.
Figured out that a lot of the errors are because I'm including nats/client inside rails.
from nats-pure.rb.
@sradu how are you including it in Rails? Is it via an initializer?
from nats-pure.rb.
Yes.
Going deeper, this is how a request looks like in raw ruby:
"{\"stream_name\":\"add-consumer-test\",\"config\":{\"durable_name\":\"test-create\",\"ack_policy\":\"explicit\",\"ack_wait\":5000000000,\"max_waiting\":3,\"max_ack_pending\":20}}"
This is how it looks like when made from rails:
"{\"stream_name\":\"add-consumer-test\",\"config\":{\"name\":null,\"durable_name\":\"test-create\",\"description\":null,\"deliver_policy\":null,\"opt_start_seq\":null,\"opt_start_time\":null,\"ack_policy\":\"explicit\",\"ack_wait\":5000000000,\"max_deliver\":null,\"backoff\":null,\"filter_subject\":null,\"replay_policy\":null,\"rate_limit_bps\":null,\"sample_freq\":null,\"max_waiting\":3,\"max_ack_pending\":20,\"flow_control\":null,\"idle_heartbeat\":null,\"headers_only\":null,\"max_batch\":null,\"max_expires\":null,\"deliver_subject\":null,\"deliver_group\":null,\"inactive_threshold\":null,\"num_replicas\":null,\"mem_storage\":null}}"
from nats-pure.rb.
Seems to be similar to #67
from nats-pure.rb.
I still have the problem with posting a message in a Rails controller method.
It returns.
NATS::IO::Timeout (nats: timeout):
It works from the rails console, which is weird.
from nats-pure.rb.
It seems to not pop here in rails:
def flusher_loop
[...]
@flush_queue.pop
from nats-pure.rb.
Plain ruby times out:
require 'nats/client'
nats = NATS.connect('127.0.0.1:4222')
psub = nats.jetstream.pull_subscribe('subject', 'durable_subject')
loop do
msgs = psub.fetch(1)
msgs.each do |msg|
puts msg.inspect
msg.ack
end
end
Returns this (I added a bunch of debug code):
flush queue pop
force-flush
["PUB $JS.API.CONSUMER.MSG.NEXT.SUBSTATION.durable_ensure_agent _INBOX.wsl2NyF0BcliULSmt7Xzq8 32\r\n{\"batch\":1,\"expires\":4999900000}\r\n"]
WAITING ON FLUSH EUEUE
flush queue pop
force-flush
["PONG\r\n"]
WAITING ON FLUSH EUEUE
/gems/ruby-3.0.1/gems/nats-pure-2.2.0/lib/nats/io/js.rb:634:in `fetch': nats: fetch timeout (NATS::IO::Timeout)
from nats-pure.rb.
@wallyqs I found two other issues for this Timeout bug.
I understand this is an OSS project and time is limited. But if this won't be fixed I have to move on and find some other way of making things work, possibly without NATS.
Thanks!
from nats-pure.rb.
Thanks @sradu I will try to have an update for it in the next couple of days, sorry for the inconvenience.
from nats-pure.rb.
Thank you! Appreciate it.
from nats-pure.rb.
Issues should be fixed via #93
Also updated example to catch for the timeout which is expected:
require 'nats/client'
nc = NATS.connect
js = nc.jetstream
js.add_stream(name: "mystream", subjects: ["foo"])
Thread.new do
loop do
# Periodically publish messages
js.publish("foo", "Hello JetStream!")
sleep 0.1
end
end
psub = js.pull_subscribe("foo", "bar")
loop do
begin
msgs = psub.fetch(5)
msgs.each do |msg|
msg.ack
end
rescue NATS::IO::Timeout
puts "Retry later..."
end
end
from nats-pure.rb.
Thank you sir! Will test everything in the next day.
from nats-pure.rb.
Fixed #93
from nats-pure.rb.
Related Issues (20)
- KV History
- Review and verify that on create of streams and consumers, naming errors are surfaced in the client
- Default Error Listener
- Don't Auto ack when Ack Policy is No Ack
- Implement Allow consumer filter subject to be updated
- Implement Support Consumer Retry Backoff and Nak delays
- Implement StreamInfo request changes to retrieve subjects
- Implement Bind subscribe validation
- Implement new pull consumer and ephemeral consumer options
- Implement MaxBytes for pull requests
- pull_consumer behaving oddly
- Implement support for Jetstream consumers with multiple subject filters
- Possible bug in nats-pure.rb/lib/nats/io /client.rb#1828 HOT 2
- NATS connection with username / password with URI Escape characters fails
- List of keys from jetstream KV
- Implement Consumer Pause
- Alternate Prefixes
- Flow Control
- Nats-Expected-Last-Sequence
- Nats-Expected-Last-Msg-Id
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nats-pure.rb.