I am using ServiceStack's JsonServiceClient with Silverlight 5 to receive JSON data from my ASP.Net server. It works perfectly for short JSON strings but when it comes to very large amounts of data, a StackOverflowException is thrown in ServiceStack.ServiceClient.Web.AsyncServiceClient.ReadCallBack<>
.
So I examined the latest source code on GitHub and noticed that the data is read block-wise from a stream as chunks of 4096 bytes. The problem is that this method reads a block and tells the stream to call itself recursively when done. The more data we receive, the more recursive calls occur. That's why the application crashes when the received data is too large.
Ideas:
Anyway, before I download all the source code, modify and compile it myself, I'd like to hear your opinion on this. Is it a bug or am I using it wrong?
There is a limitation on the string length that gets sent across the wire for your JSON response. On an external application it is likely you would never hit the default limit. However, on internal apps you may hit it since the weight is not such and issue. You need to add the following in your web.config file to max out the JSON string length.
Note that you cannot set the string length the unlimited. Also, I don't think you can go above 2147483644.
<configuration>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="2147483644"/>
</webServices>
</scripting>
</system.web.extensions>
</configuration>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With