Git Product home page Git Product logo

json-rpc.net's Issues

System.TypeInitializationException

Hi,

Recently started new project, first time running JSON-RPC service, (fresh dev environment) I get a System.TypeInitializationException when calling JsonRpcService base constructor. Specifically at bindservice. See attached screenshot.

JB
capture

error when calling method with nullable DateTime parameter

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

parameter as an array

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.

Can not comunicate when separate from message sender and message receiver.

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.

Example please

Could you please make some example programs showing your greate framework?
TestServer_Console is not enough to understand to a newbie like me.
Thanks.

Incorrect Newtonsoft.JSON framework version installed when grabbing Nuget package in VS2013 Express for desktop

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?

PostProcess

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

Register simple POCO as a service

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?

Make DLL's available for download

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.

Question about RPC service on client side

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).

Missing NuGet release

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.

Universal Windows Apps

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

x86 only configuration

Is there anything that limits us to only have x86 configuration?

Can't we have an anycpu configuration also?

StackOverflowException with LinkedList

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

"method not found" error in release version

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?

Projects using different versions of newtonsoft.json packages;

Here's the output from my packages directory;

  • Newtonsoft.Json.4.0.2
  • Newtonsoft.Json.4.5.1
  • Newtonsoft.Json.4.5.9
  • Newtonsoft.Json.4.5.10
  • Newtonsoft.Json.4.5.11
  • Newtonsoft.Json.6.0.3 (i've updated master project for so manually)
  • Rx-Main.1.0.10621
  • Rx-Main.1.0.11226

So i deleted all the packages/ and re-updated my nuget packages.

I guess this is conflicting..

Multiple instances of the exact same service

@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?

Url "routing" to group methods

(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)?

Allow ignored parameters from client

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

Threading consideration/Main UI Thread

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

Updated to newtonsoft.json 6.0.0.3

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.

Allow JsonRpc.id to be available

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?

Failing tests

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}"

Result field is missing when function returns void

// 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.

how to remove session at runtime.

@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, Dictionary2 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)

How to handle TargetInvocationException?

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

Missing optional named parameter raises an exception

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."

NuGet release and Json.NET

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.