titanium-web-proxy
titanium-web-proxy copied to clipboard
Exception when calling SessionEventArgs.GetResponseBody()
Hello,
I get the following exception sometimes when SessionEventArgs.GetResponseBody is called. I have not figured out the reasons yet. Maybe anyone knows about this.
Thanks
System.FormatException: Input string was not in a correct format. at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at Titanium.Web.Proxy.EventArguments.LimitedStream.getNextChunk() at Titanium.Web.Proxy.EventArguments.LimitedStream.Read(Byte[] buffer, Int32 offset, Int32 count) at System.IO.Stream.<>c.<BeginReadInternal>b__39_0(Object ) at System.Threading.Tasks.Task1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.IO.Stream.EndRead(IAsyncResult asyncResult)
at System.Threading.Tasks.TaskFactory1.FromAsyncTrimPromise1.Complete(TInstance thisRef, Func3 endMethod, IAsyncResult asyncResult, Boolean requiresSynchronization) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Titanium.Web.Proxy.EventArguments.LimitedStream.<Finish>d__22.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Titanium.Web.Proxy.EventArguments.SessionEventArgs.<copyBodyAsync>d__22.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Titanium.Web.Proxy.EventArguments.SessionEventArgs.<CopyResponseBodyAsync>d__21.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Titanium.Web.Proxy.EventArguments.SessionEventArgs.<readBodyAsync>d__18.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Titanium.Web.Proxy.EventArguments.SessionEventArgs.<readResponseBodyAsync>d__17.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Titanium.Web.Proxy.EventArguments.SessionEventArgs.<GetResponseBody>d__28.MoveNext()
The call stack tells that the chunked response from the server was not in correct format. It tried to parse the next chunk length from the header (to an integer) but failed due to bad format.
Is that a public website? Could you tell me please the url? (And other information that i have to do on that website)
I'd like to check the response received from the server.
Hi! Yes, it is https://youtube.com, I don't remember the exact video url.
Actually this exception happens very often in about 1/3 of all requests.
Could you tell me what locale settings do you have? Finnish? fi-FI?
I have browsers with 2 configured locales: en-US and ru-RU.
The same issue. I can't fix it about 2 hours( So I'm leaving, it's so unstable crap. Is there any alternatives for C#?
@grandsilence This project is no longer maintained, as I don't have time to contribute and other contributors are not active. Sorry, but you may check out Fiddlercore. (That's the only c# alternative I know, but last time I checked it was not absolutely free).
@justcoding121 Sad to hear. Thanks for the reply. I decided to give up C# in network things. Who is interested https://github.com/elazarl/goproxy successfully solved the problem of overwriting traffic.
I'd fix this issue, but really cannot reproduce it :(
@justcoding121 If you do not have time to contribute, could you please enable again commiting to the master branch? For me it would be easier to fix bugs directly there. I'm also not so active, but I'd like to fix some small issues.
And I think it is time to drop the NET4.5 support, upgrade to NET461, which is netstandrad 2.0. In this case a lot of #if NET45 conditions could be removed.
(Maybe release a last 4.5 version from the current master, then remove it.)
You should be able to merge PR without any approval. Possibly also commit directly to master. Did you try? @honfika
You can do whatever changes you think would be needed. No need for my input.
@antrv, @grandsilence: Please try the latest beta build. It should throw a new exception which maybe helps us to fix the issue: Invalid chunk length: '{chunkHead}'
When you get this exception message, please let me know what is between the quotes.
@justcoding121 I'll try the direct push soon. Thank you.
@honfika If you are up to maintaining the project, feel free to remove the notice I put on the readme. Thanks.
@honfika Are you planning to maintain this project and remove the note from the readme file? Thanks.
@mgerenst I'm trying to fix some smaller bugs, trying to improve the http/2 support.
What I don't have:
- Linux/Mono
- Mac
- Windows 8.1 or earlier
- Other IDE than VS 2019
So I'll give smaller priority for those issues, but PR's are welcome:)
I'd like to fix this issue, but I can"t reproduce it, so the only thing I could do is adding a better exception handling, another exception message, which could help to solve the problem.
Why do you asking?
I'll be happy to help with MAC, anyway my question is not for this issue specific and more in general are you taking ownership (or intend to support) this project?
Yes, I'd like to support this project.
@honfika Thanks for your support.
@mgerenst I've removed the disclaimer https://github.com/justcoding121/Titanium-Web-Proxy/commit/c7e34cc76e468fa6f1984b543a5f4341b7c91f52
I've discovered a new, reliable way of triggering this issue. Stream downloads. I added some caching code to cache my steam-downloads locally on my network. It seems almost every server response causes the exception. So for the sake of an easily reproducible test case, it seems to do the job.
What is the exception message?
{System.Collections.ListDictionaryInternal} called from GetResponseBody()
The exception generated is: _COMPlusExceptionCode | -532462766 | int
I'll throw in the response headers too while I'm here, as likely pertinent
[0] {Server: nginx/1.17.6}
[1] {Date: Sun, 02 Feb 2020 22:34:33 GMT}
[2] {Content-Type: application/x-steam-chunk}
[3] {Content-Length: 1062224}
[4] {Connection: keep-alive}
[5] {last-modified: Sun, 22 Dec 2019 19:19:25 GMT}
[6] {x-content-crc: 4112437831}
[7] {x-content-sha: 83679326a116485838dac8602d760571cd8be8bd}
[8] {Content-MD5: +JawS68Mlzrz+Kwt4YViMw==}
[9] {Expires: Thu, 27 Feb 2020 19:19:25 GMT}
[10] {X-Cache-Status: HIT}
Hmm, I think you coped wrong screnshot.. you sould attach the exception which was thrown... in the screenshot you are showing something in the watch window.
I tried to download a game from Stream, but it worked.
Are you sure that your exception is "System.FormatException: Input string was not in a correct format"?
Yes, I am.... Sorry, I'm being less than helpful. Since installing the Titanium package I've not been receiving stack traces in the console and having to poke around just to get the actual exceptions being thrown.
Generated from calling byte[] derp = $object.GetResponseBody in onResponse event handler.
I've never in my life known of a package to disable stack traces like that before and am somewhat flummoxed in figuring out how to turn them back on again.
I'll provide more information when I've made vs a little more cooperative.
Ok, I think the real story here if my visual studio exception handling is somehow broken.
My actual exception was caused by a null ptr in a header. Testing around that fixed that unrelated issue.
I'm really sorry for wasting your time in this way.
So in my case the issue went away when I switched from AfterResponse event to BeforeResponse event.