Closed DanielGlick closed 2 years ago
Posting this here for help. I have not seen any reports of similar issues, and I cannot find any solutions to fix this issue.
The following code works just fine for me:
byte [] testSignatureBytes = new byte []
{
0x42, 0x4d, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00, 0x28, 0x00,
0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00,
0x00, 0x00, 0x90, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80,
0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80,
0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff,
0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x70, 0x07, 0xff, 0xff,
0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x70, 0x00, 0x00, 0x7f, 0xff,
0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x70, 0x00, 0x00, 0x00, 0x07, 0xff,
0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f,
0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf7, 0x00, 0x00, 0x00, 0x7f, 0x80, 0x00, 0x07,
0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x7f, 0xff, 0xf8, 0x00, 0x00,
0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xff, 0x70, 0x00, 0x7f, 0xff, 0xff, 0xff, 0x80, 0x00,
0x7f, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00,
0x0f, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xf7, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00,
0x0f, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf7, 0x00,
0x0f, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00,
0x0f, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xf8, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00,
0x7f, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x07,
0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x70, 0x00, 0x7f, 0x00, 0x00, 0x7f,
0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x0f, 0x70, 0x00, 0x0f,
0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x7f,
0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x7f, 0xf8, 0x07, 0xff,
0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xf0, 0x00, 0x00, 0x00
};
var stream = new MemoryStream (testSignatureBytes, 0, testSignatureBytes.Length, true, true);
var requestMessage = new HttpRequestMessage (HttpMethod.Post, "https://httpbin.org/post");
requestMessage.Content = new StreamContent (stream);
requestMessage.Content.Headers.ContentType = new MediaTypeHeaderValue ("application/octet-stream");
requestMessage.Headers.TransferEncodingChunked = true;
var httpClient = new HttpClient ();
Task.Run (async () => {
var responseMessage = await httpClient.SendAsync (requestMessage, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait (false);
Console.WriteLine (responseMessage);
});
so please attach a complete test project we can use to reproduce this.
I cannot attach the app I am using to reproduce this. I will try to reproduce in an app that I can attach here. Can you spot anything from the crash error attached that could point to a problem?
Can you spot anything from the crash error attached that could point to a problem?
My guess is that it's server-dependent somehow, even though server-side breakpoint was never hit (https related? auth related? basically any kind of communication that happens between the client and the server before your server-side code is executed).
@rolfbjarne I am curious how reproduction projects are usually made. This is a unique situation because I am only reproducing it in a Release build of my app. I could create a demo application but I think to run it in release I need to have it registered with Apple correct?
Okay I have a new development here. I turned off linking in our application (previously was set to Framework SDK's only), and that seems to have fixed the issue. One other thing I should have mentioned is that this is a Xamarin Forms application.
Also, since it seems to be a linker problem, I turned on linking in Debug and that reproduces the crash.
I also noticed https://github.com/xamarin/xamarin-macios/blob/6898920c72af2bd1c6722b7cb849da2423702220/src/Foundation/NSUrlSessionHandler.cs#L1188
That comment seems to describe a very similar issue as what I am seeing.
@rolfbjarne I am curious how reproduction projects are usually made.
Just create a new project from a template, change it so that it fails the same way, zip it up and attach it here.
We were able to work around the issue by setting the httpclient of our app to managed vs NSUrlSession. Also turning on linking to framework skds only we were able to reproduce this in debug. I will try to get a reproduction project created so you can debug this in your end. Seems like it definitely is related to my comment above. @rolfbjarne Thoughts on my comment above in NSUrlSessionHandler.cs?
I will try to get a reproduction project created so you can debug this in your end. Seems like it definitely is related to my comment above.
That would be great!
Thoughts on my comment above in NSUrlSessionHandler.cs?
Yes, it could very well be related. However, until I can reproduce the issue myself, I can't know for sure.
If we have a repro project I can take a look at this issue. I am also curious (because I know the NSUrlSessionHandler well) if you have the same issue when the method is not using async.
We have not got any reproducible test case to investigate the issue. If you can get one please open a new issue, attach the test case, and reference this (original issue). Thanks!
I got the same error. When I take an image from the gallery and convert it to a base64 string everything works as intended. But as soon as I take a picture directly with the camera and send its Base64 string I get this error.
I use Http and the HttpClient to send the data.
Unfortunately I can't create a project which is the same as it is a productive system.... On the other side is a windows service which works with the netframework. This one receives my requests.
When I do the same on Android I don't get any errors. Also, I can enable NSAllowsArbitraryLoads
which fixes the error more or less. But this is not a nice variant!
I have found a possible cause in my case. 🥴 Most likely you set up an HttpClient like this or used the default timeout:
httpClient = new HttpClient { Timeout = TimeSpan.FromSeconds(5)};
Xamarin has a lot of problems with the timeout from the HttpClient. Among other things, that the timeout is ignored when fetching data. When sending, this timeout is strangely respected. That means, as soon as your sending takes too long it will be aborted. This should be recorded as a bug and fixed... (Better error message / fix HttpClient)
Steps to Reproduce
Expected Behavior
Should send the request containing the stream to the server
Actual Behavior
App crashes from a native exception...
SIGABRT: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: *** -streamStatus only defined for abstract class. Define -[System_Net_Http_NSUrlSessionHandler_WrappedNSInputStream streamStatus]
I can verify that this is not an issue on the servers end. I put a breakpoint on the POST Route and it was never hit.
Environment