I am building a P2P Network with nancy. So far everything has gone fine. Now i am building my fingertables and want to parse them on using to other clients. But I get the following error:
Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value
My Request:
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = await client.GetAsync($"http://localhost:{port}/Successor/{id}");
var chord = await response.Content.ReadAsAsync<ChordNode>();
return chord;
}
which just returns:
Get["Successor/{id}", true] = async (x, ct) =>
{
return _chordNode;
};
My class ChordNode worked fine until i added FingerTable list. It looks like the following:
public class ChordNode
{
public NodeInfo Info { get; set; }
public NodeInfo Successor { get; set; }
public NodeInfo Predecessor { get; set; }
public List<ChordNode> FingerTable { get; set; }
..... and other stuff thats not important.
If i make FingerTable private, it works again, but then i don't get my FingerTable
returned to the other clients.
Still pretty new to asking questions on StackOverflow. So any feedback would be nice :)
I found a solution. After i removed all my ASYNC i got a better message telling me i used this part wrong.
Get["Successor/{id}", true] = async (x, ct) =>
i used my parameter x.id as a int in a method call and it gave me no feedback whatsoever. So after parsing this to a int it solved everything thing.
Thanks for all the nice feedback.