bgmulinari / B1SLayer

A lightweight SAP Business One Service Layer client for .NET

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sometimes, the request fails

qcsfb opened this issue · comments

First of all thanks for the great work you have done with the B1SLayer, I hope that all the time you have saved us developers to implement the service layer, will be returned to you in life.

My issue is that sometimes the calls fail me and the code below is the trace. See if you can see something, if you need more information, let me know.

   at System.Net.Http.HttpConnection.<SendAsyncCore>d__61.MoveNext()
   at System.Net.Http.HttpConnectionPool.<SendWithVersionDetectionAndRetryAsync>d__86.MoveNext()
   at System.Net.Http.DiagnosticsHandler.<SendAsyncCore>d__10.MoveNext()
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.DecompressionHandler.<SendAsync>d__16.MoveNext()
   at System.Net.Http.HttpClient.<<SendAsync>g__Core|83_0>d.MoveNext()
   at Flurl.Http.FlurlRequest.<SendAsync>d__29.MoveNext()

Hi, @qcsfb. Thank you for your kind words.

Unfortunately, the trace you provided is not enough information to help me understand the cause of the issue. Could you maybe provide a code snippet of a request using B1SLayer where you observe the issue? What's the exception you get?

If I can reproduce the issue on my end, that would be ideal.

Hi, i enabled logs in the service layer and the trace of a example (post orders)

 [proxy_http:error] [pid 24460:tid 1100] (OS 10054)Se ha forzado la interrupci�n de una conexi�n existente por el host remoto.  : [client ::1:59952] AH01102: error reading status line from remote server 127.0.0.1:50002
 [proxy:error] [pid 24460:tid 1100] [client ::1:59952] AH00898: Error reading from remote server returned by /b1s/v1/CompanyService_GetCompanyInfo
 [proxy_http:error] [pid 24460:tid 1100] (OS 10054)Se ha forzado la interrupci�n de una conexi�n existente por el host remoto.  : [client ::1:60280] AH01102: error reading status line from remote server 127.0.0.1:50003
 [proxy:error] [pid 24460:tid 1100] [client ::1:60280] AH00898: Error reading from remote server returned by /b1s/v1/CompanyService_GetCompanyInfo
 [proxy_http:error] [pid 24460:tid 1088] (OS 10054)Se ha forzado la interrupci�n de una conexi�n existente por el host remoto.  : [client ::1:60358] AH01102: error reading status line from remote server 127.0.0.1:50010
 [proxy:error] [pid 24460:tid 1088] [client ::1:60358] AH00898: Error reading from remote server returned by /b1s/v1/CompanyService_GetCompanyInfo
 [proxy_http:error] [pid 24460:tid 1088] (OS 10054)Se ha forzado la interrupci�n de una conexi�n existente por el host remoto.  : [client 192.56.162.59:55930] AH01102: error reading status line from remote server 127.0.0.1:50009
 [proxy:error] [pid 24460:tid 1088] [client 192.56.162.59:55930] AH00898: Error reading from remote server returned by /b1s/v1/Orders
 [proxy_http:error] [pid 24460:tid 1100] (OS 10054)Se ha forzado la interrupci�n de una conexi�n existente por el host remoto.  : [client ::1:60923] AH01102: error reading status line from remote server 127.0.0.1:50002
 [proxy:error] [pid 24460:tid 1100] [client ::1:60923] AH00898: Error reading from remote server returned by /b1s/v1/CompanyService_GetCompanyInfo

I dont think if this is helpful for you.

@qcsfb, What's the .NET version you are using for your project?

Net standard 2.1

You use .NET Standard in a project type of class library, right? I mean the project of the application that compiles into an executable.

There can be problems with old .NET Framework versions where you can set the TLS version globally and it should fix this issue:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

This should be done at your application startup (not the class library project). Let me know if it helps.

To answer your first question. The structure of my project is as follows. I have a main project that is a minimal API in .net7 that uses another project (where your library is) that uses standard 2.1.

@qcsfb, from what I could investigate so far, this could be related to your client and server not agreeing on the TLS version. However, this is just one of the possibilities.

A number of factors like the .NET version or the OS configuration could be causing this, so a further investigation on your environment would be needed to nail it down to the exact cause.

You can try adding additional TLS versions to your application, overwriting any .NET or OS configuration. Add the line below in the startup (Program.cs) of your .NET 7 API project and see if it fixes the issue.

ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

In any case, I don't believe this issue is directly related to B1SLayer.

Hi, thanks for your time, you are right. I think is not related to B1SLayer because I tried with insomnia (its like postman) and sometimes i get proxy error.

image

I think its something wrong in my server, do have any idea what could be the reason of this problem??

The question is that even the error occurs, the order is inserted in sap!!! and this also occurs with B1SLayer...

Thanks a lot.

Indeed, this indicates that there is something wrong on the server side. I believe it could be related to the Service Layer installation or the HTTP server itself (Apache), but this is just speculation on my part.

I recommend you asking a question in the official SAP Community page with the "SAP Business One Extensibility" tag. Or, if you can, report an incident directly to the SAP Business One Support Team under the component "SBO-SDK-SVL".

Thank you for ur fast response. I will ask in the sap forum. I think if I fix issue in the service layer it will be fixed in B1SLayer

thanks, a lot!