segmentio / Analytics-CSharp

The hassle-free way to add Segment analytics to your C# written app (.Net/Xamarin/Unity).
MIT License
21 stars 8 forks source link

MAUI - Unknown network error EOF #103

Closed dimitri-dev closed 5 months ago

dimitri-dev commented 6 months ago

Describe the bug Segment.Analytics.AnalyticsError Unknown network error when uploading to url -> unexpected end of stream on com.android.okhttp.Address@1599a963 -> \n not found: size=0 content=...

To Reproduce Just occurs in the background while running a .NET 8 (Runtime 8.0.4) MAUI app. This is just a (relatively) simple native Android and iOS project.

Raw stack trace

Java.IO.IOException: unexpected end of stream on com.android.okhttp.Address@1599a963 ?, in int InstanceMethods.CallIntMethod(JniObjectReference, JniMethodInfo, JniArgumentValue) ?, in int JniInstanceMethods.InvokeVirtualInt32Method(string, IJavaPeerable, JniArgumentValue) ?, in HttpStatus HttpURLConnection.get_ResponseCode() ?, in Task AndroidMessageHandler.DoProcessRequest(HttpRequestMessage, URL, HttpURLConnection, CancellationToken, RequestRedirectionState)+() => { } ?, in void Task.InnerInvoke() ?, in async Task AndroidMessageHandler.DoProcessRequest(HttpRequestMessage, URL, HttpURLConnection, CancellationToken, RequestRedirectionState) ?, in async Task AndroidMessageHandler.DoSendAsync(HttpRequestMessage, CancellationToken) System.Net.WebException: unexpected end of stream on com.android.okhttp.Address@1599a963 ?, in async Task AndroidMessageHandler.DoSendAsync(HttpRequestMessage, CancellationToken) ?, in async Task HttpClient.SendAsync(HttpRequestMessage)+Core(?) ?, in async Task DefaultHTTPClient.DoPost(string url, byte[] data) ?, in async Task HTTPClient.Upload(byte[] data)

Additional context Currently using Segment.Analytics.CSharp 2.3.5.0 release.

dimitri-dev commented 6 months ago

@wenxi-zeng I'm not sure if this is the best way to go about this, but if you can take a look at #104, it should solve this issue as I've already encountered it in MAUI recently.

wenxi-zeng commented 6 months ago

hi @dimitri-dev, thanks for contributing! the pr looks good. we will thoroughly test it on other platforms and then ship it in the next release. in the meanwhile, please write a custom httpclient as a workaround.

wenxi-zeng commented 5 months ago

@dimitri-dev the fix is shipped in the new release 2.4.1. please have a try. thanks again for your contribution