Expand my Community achievements bar.

Custom servlet on publisher

Avatar

Level 4

I'm trying to set up a new servlet in AEM. It works on the AEM author but not the publisher. (I'm getting a 504 Gateway Timeout)

Is there a setting in OSGi that I need to configure? It shows the correct class when I check the Sling Servlet Resolver. Thanks.

 

i.e. /bin/checkStatus

4 Replies

Avatar

Community Advisor

@stiegjo22  if this is a path based servlet, can you please check if the servlet path is allowed from your Dispatcher's Filters.any file?  I am assuming that you have a dispatcher in front of your publisher instance. 

Avatar

Community Advisor

@stiegjo22 few things to consider

1. Are you trying direct publisher access or dispatcher domain infront of publisher? If dispatcher present have you make sure you have allowed all paths needed for your servlet.

2. Is your servlet path based or resource type based?

3. Have you negotiated servlet authentication?

4. Have you looked into referer config?

Avatar

Community Advisor

Hi, 

 

If you're getting a 504 error, it means the servlet could not complete its processing within the allowed time. By default, there is a timeout for expensive operations to safeguard the server's integrity. There could be many reasons for this, so the best approach is to check the logs and investigate further. From what I've observed, the issue is often related to processing a large volume of content that is not available on the author instance, making it non-reproducible both locally and in the author environment.

 

You have several options to address this:

  • Identify any bottlenecks in your code and resolve them.
  • Switch to a Sling Job.
  • Increase the timeout (though this is not recommended).

 

Please check these threads which can help you with the above options: 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/timeout-gateway-error-504-...

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-set-timeout-for-sli...

https://stackoverflow.com/questions/26742580/504-gateway-time-out-the-server-didnt-respond-in-time-h...

 

Hope this helps



Esteban Bustamante

Avatar

Community Advisor

If you're using a dispatcher in front of the publisher, the servlet endpoint (e.g., /bin/checkStatus) might not be accessible due to the dispatcher rejecting or blocking the /bin/ path.

/filter
{
  /0069
  {
    /type "allow"
    /url "/bin/checkStatus"
  }
}