astn / json-rpc.net Goto Github PK
View Code? Open in Web Editor NEW.Net JSON RPC framework
License: MIT License
.Net JSON RPC framework
License: MIT License
nevermind
No support .NET Core. It is planned in the future?
I have the following RPC method to test nullable DateTime parameter and returned value.
[JsonRpcMethod]
DateTime? GetDateTimeNullable(DateTime? p)
{
return p;
}
But I got an error as followed.
{"jsonrpc":"2.0","error":{"code":-32603,"message":"Internal Error","data":{"ClassName":"System.ArgumentException","Message":"Value of type 'Newtonsoft.Json.Linq.JValue' cannot be converted to 'System.Nullable`1[System.DateTime]' ." ... }
regards.
Shusen
So one of my json-rpc calls can have 0,1 or n+ elements in a field;
{ 'id' : 1, 'method' : 'mining.subscribe', 'params' : [ ] }
{ 'id' : 1, 'method' : 'mining.subscribe', 'params' : [ 'cgminer/3.7.2' ] }
{ 'id' : 1, 'method' : 'mining.subscribe', 'params' : [ 'cgminer/3.7.2', 'aaaaa' ] }
tried different method signatures but can't get it working
[JsonRpcMethod("mining.subscribe")]
public SubscribeResponse SubscribeMiner(params object[] parameters)
tried;
public SubscribeResponse SubscribeMiner(params object[] parameters)
public SubscribeResponse SubscribeMiner(object[] parameters)
public SubscribeResponse SubscribeMiner(object[] parameters = null)
public SubscribeResponse SubscribeMiner(params string[] parameters)
public SubscribeResponse SubscribeMiner(string[] parameters)
public SubscribeResponse SubscribeMiner(string[] parameters = null)
public SubscribeResponse SubscribeMiner(IList<string>)
help appriciated.
JsonRequest
class has no JSON-RPC version, can somebody explain why? Is there any particular reason?
nevermin
Hi all,
We find a problem about comunication and need to solve.
First at all, the html page(message sender) and winform application(message receiver) can comunication at same webbroswer.(the winform application embedded a geckoWebBrowser1)
geckoWebBrowser1.AddMessageEventListener("JsonRpcBridge", this.JsonRpcBridge); geckoWebBrowser1.Navigate(System.IO.Path.Combine(Application.StartupPath, "www", "index.html"));
But, if separate them,the winform application run as a message receiver to listen html page's message,while the html page run as a message sender at firefox or chrome browser. Unfortunately, the winform application can not receive any message from html page. we don't know is it the html page haven't send message or the winform application can not recevie message.
geckoWebBrowser1.AddMessageEventListener("JsonRpcBridge", this.JsonRpcBridge); //geckoWebBrowser1.Navigate(System.IO.Path.Combine(Application.StartupPath, "www", "index.html")); // run this url(System.IO.Path.Combine(Application.StartupPath, "www", "index.html")) at firefox or chrome broswer
Please help us solve the problem, we will thank you a lot.
Please, make a bidirectional Console or Socket example on Wiki. Thanks.
There is one in the Json.Rpc folder.
Could you please make some example programs showing your greate framework?
TestServer_Console is not enough to understand to a newbie like me.
Thanks.
Need to make sure we have tests for each of the CLR value types
Hey all,
I've been using JSON-RPC.NET for the last few years. I recently updated my 2 year old version of the framework (downloaded manually back in the day) and updated to the latest using VS's built in Nuget Package manager. As part of the update, the NewtonSoft JSON framework is also installed as a dependency.
When next building my application, I got this exception:
InnerException {"Could not load file or assembly 'Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.":"Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed"} System.Exception {System.IO.FileNotFoundException}
The version installed with the NuGet package was 6.0.0.5. I downloaded the latest Nuget version of NewtonSoft JSON and all was well, I wrote this off as fluke.
However, I just today started a fresh Solution, and after installing the Nuget package, I got the same issue again. Could the dependencies on the Package be incorrect?
Hi all, first off great library thanks so much for this! I'm trying to use this in an application where ideally I'd like a PostProcess in almost the same way there's PreProcess right now, essentially i want to audit all activity on the wire (simply put it's going to throw the request, response, ip address, ... into a file with a bit of obfuscation of sensitive data). How would you feel about me adding this as a standard feature, i figure something like adding the callback into
https://github.com/Astn/JSON-RPC.NET/blob/master/Json-Rpc/JsonRpcProcessor.cs#L103
would be a relatively trivial affair without too much performance impact and provide the callback i'm looking for; obviously this doesn't quite catch every case where exceptions are thrown before we get to that code but i believe that's pretty much the same as PreProcess so don't see a big issue with that but interested in everyone's thoughts as to whether or not this is valuable as a core function.
Many thanks
Christopher
And better move the documentation & stuff too.
I would like to register a simple POCO with methods marked by [JsonRpcMethod]
. I.e. I would like to have JsonRpcService.buildService
as a public (static) method. May be in the 'Handler' class or some other class?
BTW. why the buildService
call public method Handler.Register()
by reflection?
Please please please make dll's availbale for direct download.
Nuget just doesn't work. Each time I spend hours trying to make it work, IT JUST DOESN'T.
It would save so much time if i could just download and reference dll files.
Forcing the old IAsyncResult pattern is a pain.
Hello,
Can this package be used when we have reverse server-client structure.
In my case client will connect to web socket server and then server should be able to make remote calls to client (which will be implemented on client).
I see today, that the release v1.0.4.33 was not published to NuGet. Can you please publish it? Thanks for your good work.
Found this on the codeplex site.
jay_fin
Aug 6, 2015 at 4:32 AM
Hello,Any plans on converting the project to support Universal Windows Apps? It would be great, if I could use json-rpc.net on my Raspberry Pi2 + Windows IoT core 10.
-j
Is there anything that limits us to only have x86 configuration?
Can't we have an anycpu configuration also?
If there is a parse error, there is no clean way to clean it up before passing it back to the caller.
Need to add more tests for optional parameters
I have simple data class.
public class Test
{
private Question currentQuestion;
public event Action<Question> OnNext;
public event Action OnFinished;
public LinkedList<Question> Questions { get; }
}
When i create my service with method
[JsonRpcMethod]
public Test GetTest(int questionsCount)
{
....
}
VS lock and after some times throw StackOverflowException
If i change Questions type to List<> exception not throw
Shouldn't we updating nuget package from github?
If I publish my web service, and therefore also build in release mode I get the following error.
Each method call returns "Method not found" error.
{"jsonrpc":"2.0","error":{"code":-32601,"message":"Method not found","data":"The method does not exist / is not available."},"id":1}
Why is this so?
Here's the output from my packages directory;
So i deleted all the packages/ and re-updated my nuget packages.
I guess this is conflicting..
@Astn In CoiniumServ we need to host multiple instances of exact same service which those can just listen on different ports and have different contextual information.
Though getting this exception;
An exception of type 'System.ArgumentException' occurred in mscorlib.dll but was not handled in user code
Additional information: An item with the same key has already been added.
----
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at AustinHarris.JsonRpc.SMD.AddService(String method, Dictionary`2 parameters, Dictionary`2 defaultValues) in d:\temp\tmp613C\Json-Rpc\SMDService.cs:line 41
at AustinHarris.JsonRpc.JsonRpcService.buildService(String sessionID) in d:\temp\tmp613C\Json-Rpc\JsonRpcService.cs:line 60
at AustinHarris.JsonRpc.JsonRpcService..ctor() in d:\temp\tmp613C\Json-Rpc\JsonRpcService.cs:line 14
at Coinium.Server.Mining.Stratum.Service.StratumService..ctor(IShareManager shareManager) in e:\Coding\CoiniumServ\src\CoiniumServ\Server\Mining\Stratum\Service\StratumService.cs:line 39
at lambda_method(Closure , Object[] )
at Nancy.TinyIoc.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options)
Any workarounds?
(if I could, I'd mark this low priority). One of the things I like about this library is that it doesn't overcomplicate things like forcing you to define routing paths for everything.
However, I have a circumstance where I'm trying to simulate another system which does have multiple paths at the end of which support different methods... so:
/foo/bar/baz supports all "baz"-object related methods where as /foo/bar/quz supports all "quz"-object related methods. Ignoring, for a moment, that this makes it look more like REST than JSON-RPC, is there any way to do this, or would there be any interest in having this feature (besides me at least)?
Need to check all task usage, make sure we are using correct patterns
There are some methods where my client application is sending too many parameters from the client and i'd just like these to be ignored if possible. How would you feel about about a config property AllowIgnoredParameters that would default to False but could be used then to bypass the exception on 317 of Handler.cs? Many thanks, Christopher
Great library, would be ideal if documentation or sample application could show optimal method of calling into the main UI thread. The RPC mechanism exists on a separate thread, and so the RPC function is unable to get or set any aspect of the UI. Although in most cases one would use this library with a console or asp app, using with wpf isn't uncommon and that is where it would be very useful
I've been the project using netwonsoft.json v6.0.0.3 quite a while.
Shouldn't we update the packages.conf so it uses it by default.
And our current nuget configuration tends to updated to 6.0.0.3 instead of using 4.5 series.
I found this request over on the old codeplex site.
TakashiImoto
Jul 11, 2015 at 8:53 AM
I want to get JsonRequest's Id in invoked method when json data is in request body.
Can I get JsonRequest's Id?
These tests are failing
FloatToFloat
"{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32603,\"message\":\"Internal Error\",\"data\":{\"ClassName\":\"System.ArgumentException\",\"Message\":\"Object of type 'Newtonsoft.Json.Linq.JValue' cannot be converted to type 'System.Single'.\",\"Data\":null,\"InnerException\":null,\"HelpURL\":null,\"StackTraceString\":\" at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)\\r\\n at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)\\r\\n at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)\\r\\n at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)\\r\\n at System.Reflection.RuntimeMethodInfo.UnsafeInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)\\r\\n a
t System.Delegate.DynamicInvokeImpl(Object[] args)\\r\\n at System.Delegate.DynamicInvoke(Object[] args)\\r\\n at AustinHarris.JsonRpc.Handler.Handle(JsonRequest Rpc, Object RpcContext) in e:\\\\Coding\\\\JSON-RPC.NET\\\\Json-Rpc\\\\Handler.cs:line 309\",\"RemoteStackTraceString\":null,\"RemoteStackIndex\":0,\"ExceptionMethod\":\"8\\nTryChangeType\\nmscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\\nSystem.RuntimeType\\nSystem.Object TryChangeType(System.Object, System.Reflection.Binder, System.Globalization.CultureInfo, Boolean)\",\"HResult\":-2147024809,\"Source\":\"mscorlib\",\"WatsonBuckets\":null,\"ParamName\":null}},\"id\":1}"
NullableFloatToNullableFloat
"{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32603,\"message\":\"Internal Error\",\"data\":{\"ClassName\":\"System.ArgumentException\",\"Message\":\"Object of type 'Newtonsoft.Json.Linq.JValue' cannot be converted to type 'System.Nullable`1[System.Single]'.\",\"Data\":null,\"InnerException\":null,\"HelpURL\":null,\"StackTraceString\":\" at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)\\r\\n at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)\\r\\n at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)\\r\\n at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)\\r\\n at System.Reflection.RuntimeMethodInfo.UnsafeInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo
culture)\\r\\n at System.Delegate.DynamicInvokeImpl(Object[] args)\\r\\n at System.Delegate.DynamicInvoke(Object[] args)\\r\\n at AustinHarris.JsonRpc.Handler.Handle(JsonRequest Rpc, Object RpcContext) in e:\\\\Coding\\\\JSON-RPC.NET\\\\Json-Rpc\\\\Handler.cs:line 309\",\"RemoteStackTraceString\":null,\"RemoteStackIndex\":0,\"ExceptionMethod\":\"8\\nTryChangeType\\nmscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\\nSystem.RuntimeType\\nSystem.Object TryChangeType(System.Object, System.Reflection.Binder, System.Globalization.CultureInfo, Boolean)\",\"HResult\":-2147024809,\"Source\":\"mscorlib\",\"WatsonBuckets\":null,\"ParamName\":null}},\"id\":1}"
// Pulled from a post at codeplex by Abaddon4 @ https://jsonrpc2.codeplex.com/discussions/654555
Hi!
Library return json object {"jsonrpc": "2.0", "id":1} if function return type is void. I think its wrong answer. The answer must be {"jsonrpc": "2.0", "id":1, "result":null} or {"jsonrpc": "2.0", "id":1, "result":{}}.
JSON RPC 2.0 standart:
result
This member is REQUIRED on success.
Either the result member or error member MUST be included, but both members MUST NOT be included.
So you can see that if function has no error then is successed, and it REQUIRED to have result. Please tell me if i wrong.
@Astn in my project many instance created with different key. and i want to dispose to any of them at runtime and any case
i can recreate it runtime again but it show me this error. it means key is not remove or disposed, so how can i achieve this.
An exception of type 'System.ArgumentException' occurred in mscorlib.dll but was not handled in user code
Additional information: An item with the same key has already been added.
at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at AustinHarris.JsonRpc.SMD.AddService(String method, Dictionary
2 parameters, Dictionary`2 defaultValues) in d:\temp\tmp613C\Json-Rpc\SMDService.cs:line 41
at AustinHarris.JsonRpc.JsonRpcService.buildService(String sessionID) in d:\temp\tmp613C\Json-Rpc\JsonRpcService.cs:line 60
at AustinHarris.JsonRpc.JsonRpcService..ctor() in d:\temp\tmp613C\Json-Rpc\JsonRpcService.cs:line 14
at Coinium.Server.Mining.Stratum.Service.StratumService..ctor(IShareManager shareManager) in e:\Coding\CoiniumServ\src\CoiniumServ\Server\Mining\Stratum\Service\StratumService.cs:line 39
at lambda_method(Closure , Object[] )
at Nancy.TinyIoc.TinyIoCContainer.ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options)
When I call for many JsonRpcMethod, I receive after a while a TargetInvocationException exception, and the server fails.
Why this exception occurred? And how can I catch it (to restart the server for example)
Thanks!
The version used is 1.0.4.0
Wrong json serialization in case if method haven't parameters. For more info see there:
cinemast/libjson-rpc-cpp#134
Fix this bug pls
For example:
{"jsonrpc":"2.0", "method": "subtract", "params":{"subtrahend": 23, "minuend": 42}, "id": 3}
I don't find such examples in TestClient. Thanks!
I would like to ask to add the ability to configure serialization if you have time for this.
Let's take a method
[JsonRpcMethod]
string Test(int number, string mandatory, string optional = null)
{
if (optional == null)
return mandatory
else
return mandatory + optional;
}
As method signature goes, this method has one optional parameter. So if I make a calls using positional parameters:
Call:
{"method":"Test","params":[3,"mand", "opt"],"id":1}
Result is "mandopt" as expected.
Call of method with just one parameter. Optional parameter takes the default value null
{"method":"Test","params":[3,"mand"],"id":1}
Result is "mand" as expected.
The problem occurs if we use named parameters:
Call
{"method":"Test","params":{"number":3,"mandatory":"mand", "optional":"opt"},"id":1}
behaves as expected producing "mandopt".
but
{"method":"Test","params":{"number":3,"mandatory":"mand},"id":1}
results in System.ExceptionAustionHarris.JsonRpcException with message: "Named parameter 'optional' was not present."
I have tried to use JSON-RPC.NET with the latest Json.NET version 7.0.1. But it seems not to work with JSON-RPC.NET:
System.TypeInitializationException: The type initializer for 'AustinHarris.JsonRpc.Handler' threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at AustinHarris.JsonRpc.SMD..ctor()
at AustinHarris.JsonRpc.Handler..ctor(String sessionId) in d:\temp\tmp52ED\Json-Rpc\Handler.cs:line 35
at AustinHarris.JsonRpc.Handler..cctor() in d:\temp\tmp52ED\Json-Rpc\Handler.cs:line 29
--- End of inner exception stack trace ---
at AustinHarris.JsonRpc.Handler.DefaultSessionId()
at AustinHarris.JsonRpc.JsonRpcService..ctor() in d:\temp\tmp52ED\Json-Rpc\JsonRpcService.cs:line 13
at Example006.MyJSONRPCService..ctor()
at Example006.Program.Main(String[] args)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.