Comments (10)
Thanks for your applying message.
We add try catch, but it didn't work.
Our steps:
- New EtcdClient
- Call WatchRange method
- Everying was perfect
- We close the etcd service (or close the local network) after a few seconds
- An Grpc.Core.RpcException unhandled exception occurred!
I guess the reason is as follows:
In the method of WatchRange (line 649 in watchClient.cs), you add try catch outside the Task.Run.
So "await watcher.ResponseStream.MoveNext()" will throw exception when network disconnected.
Maybe you can add try catch "inside" the Task.Run, and notify user when error occurred by calling custom error handler Action or triggering error event.
from dotnet-etcd.
Some problem here
from dotnet-etcd.
Try Something like this:
try
{
// Your code here
} (RpcException ex) when (ex.StatusCode == StatusCode.Unavailable)
{
// Do something with the exception.
}
RpcException
is a part of Grpc.Core
which should be automatically added when you add my lib.
@Kuo-Chun-Ting @tung-lin Let me know if it works for you.
from dotnet-etcd.
Oh I see. You want an exception after the watch has been initiated and network disconnects thereafter. I will push these changes. Or if you want to make a PR, you are most welcome.
from dotnet-etcd.
Some EtcdClient event or static event that can help us to catch exception in this situation.
@tung-lin Do you mean that you are able to get an exception but rather want the exception handled through some event handler that can be passes as a parameter ?
from dotnet-etcd.
@shubhamranjan Passing event handler (Action) as a parameter sounds good and better than event delegate.
In this way, we can clearer know where the error comes from and call the Watch/WatchRange method again.
from dotnet-etcd.
@tung-lin I have pushed the changes ( #35 ) but it would take me a while to release a new build as I plan to release it with fixes to other issues. In the meantime, you can test the changes and if possible, do give a feedback whether it helps you or not.
from dotnet-etcd.
Thanks for your help.
BTW, how should we watch prefix key using "WatchRange" method?
Our key is "schedule/", and we want to watch all keys under "schedule/" (schedule/1, schedule/2, schedule/xxx)
We don't know how to set the RangeEnd parameter.
If we set ByteString.CopyFromUtf8("\0"), it watch almost all keys...
from dotnet-etcd.
Try out the overloads available which take the prefix path and do it for you.
E.g. public void WatchRange(string path, Action<WatchResponse> method, Metadata headers = null)
There are many more similar overloads available.
from dotnet-etcd.
@tung-lin and future viewers
To set range end based on prefix path, try
RangeEnd = ByteString.CopyFromUtf8(EtcdClient.GetRangeEnd(prefix))
from dotnet-etcd.
Related Issues (20)
- Support IConfiguration and DI
- Exception type when cancelling async operations HOT 4
- Prefix request with Limit HOT 2
- How to read past version of keys HOT 2
- add separated community contrib project or repo HOT 1
- GrpcChannelOptions parameter configuration HOT 2
- Lock permission denied HOT 5
- Possible NullReference HOT 3
- Add optional ExceptionHandler in LeaseKeepAlive HOT 1
- Invalid port specified HOT 1
- method name is misspelled HOT 1
- Cannot use constructor EtcdClient(string) anymore HOT 1
- Exception while opening a watch on etcd grpc-proxy
- Watch stops listening to changes after server restart HOT 3
- IClusterProvider I need to implement this interface. HOT 2
- Failing to initiate with ambiguous and crashing with this exception 6.0.2-beta
- lock error HOT 2
- missing Election request HOT 1
- Switch to license expression
- new EtcdClient Expected,Please give more Example to new player HOT 1
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 dotnet-etcd.