Skip to Content
Author's profile photo Joerg Aldinger

How to avoid “502 Proxy Error” when adding large documents via Service Layer

If you have ever tried to add large documents (500+ lines) to SAP Business One using SAP Business One Service Layer on HANA, you may have encountered the following error:

502 Proxy Error

The proxy server received an invalid response from an upstream server.

The proxy server could not handle the request POST /b1s/v1/InventoryGenEntries

Reason: Error reading from remote server

However, even if you got the error message, which is basically a timeout between the Apache Load Balancer and one of its members, you may notice sometime later, that the document (or business object in general) was created successfully.

The solution is quite simple:

Log into your HANA server, and open the /usr/sap/SAPBusinessOne/ServiceLayer/conf/httpd-b1s-lb.conf file.

Within the file, change the following section, adding the line in red:

<Proxy balancer://mycluster>

  BalancerMember http://localhost:50001/b1s route=node0

  BalancerMember http://localhost:50002/b1s route=node1

  BalancerMember http://localhost:50003/b1s route=node2

  ProxySet stickysession=ROUTEID


ProxyTimeout 1800

The timeout value is expressed in seconds, which means 1800 gives you 30 minutes as maximum timeout. That should be more than sufficient for documents with 5000 lines including bin allocations.

After that, restart your Service Layer (/etc/init.d/b1s restart) and try again!

Let me know if you have any comments!


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Chin Chong
      Chin Chong

      Hi Joerg,

      We had the same error. After reading your post, we change the setting to 1800  and restarted B1 service layer. However we continue this morning, to have the same errors after 1 hour. Our application auto imports several text files. The first step is to write into an UDT from the text file - row by row, calling B1SL, from WCF SaveChanges() method. Next, also using WCF Save Changes(), we write from the UDT into B1 standard tables, row by row. This morning the error occurred when the program automatically switch to the next file to be imported. Previously the error arose halfway when reading the same text file. Our setting for the HttpWebRequest is Request.KeepAlive=false and Request.ProtocolVersion = HttpVersion.Version10. Each text file ranges from few thousands up to 12,000 rows. Please let us know if you have any ideas how to resolve this. Thank you.

      Author's profile photo Joerg Aldinger
      Joerg Aldinger
      Blog Post Author

      Hi Chin:


      I am not sure whether your error is the same as mine. Generally the timeout is reset with each request, so if one request succeeds the next will also restart the timeout counter from zero.


      Maybe you can split your request in several smaller requests? Otherwise I would send a ticket to SAP Support or your local solution architecht to see if they can help you pinpoint the issue...


      Best regards,



      Author's profile photo Cristina Espinoza
      Cristina Espinoza


      Could you resolve the proxy error? How?

      Best regards,