Custom servlet on publisher | Community
Skip to main content
stiegjo22
Level 4
December 2, 2024
Solved

Custom servlet on publisher

  • December 2, 2024
  • 4 replies
  • 952 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by stiegjo22

The workaround is to use the internal IP address for the publishers. Thanks.

4 replies

Harwinder-singh
Community Advisor
Community Advisor
December 2, 2024

@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. 

Shashi_Mulugu
Community Advisor
Community Advisor
December 3, 2024

@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?

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
December 3, 2024

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-and-connection-is-failing-at-the/m-p/688474

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-set-timeout-for-sling-servlet-in-aem6-4/td-p/311592

https://stackoverflow.com/questions/26742580/504-gateway-time-out-the-server-didnt-respond-in-time-how-to-fix-it

 

Hope this helps

Esteban Bustamante
BrianKasingli
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
December 7, 2024

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" } }

 

stiegjo22
stiegjo22AuthorAccepted solution
Level 4
December 16, 2024

The workaround is to use the internal IP address for the publishers. Thanks.