logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Other Software View previous topic :: View next topic
Reply to topic   Topic: Unable to have Server Sent Events working Apache+Tomcat
Author
Raoul.Lector



Joined: 10 Apr 2019
Posts: 2
Location: France

PostPosted: Wed 10 Apr '19 14:00    Post subject: Unable to have Server Sent Events working Apache+Tomcat Reply with quote

Hi all,

I'm using Apache 2.4.10 on Debian tied with Tomcat 8.0.28.
Tomcat hosts several Web Apps, all routed through a ProxyPass directive (such as ProxyPass /webapp1 ajp://10.10.12.2:8015/webapp1, ProxyPass /webapp2 ajp://10.10.12.2:8015/webapp2, and so on).

My Web Apps works fine, excepted when it comes to broadcast notifications through SSE.
After a few minutes, Tomcat goes crazy, stops serving pages (HTTP 500) and sometimes mixes SSE contents with regular HTML flow.

Important notice : in development environment, all the SSE stuff works perfectly, that is when we run Tomcat without Apache, under Windows 7 / 10.
This detail and what I read in the logs convince me that the problem lies in Apache.

If I'm not wrong, has someone got some hints about the config I should set in Apache ?
Or is Apache definitevely unable to process SSE requests and I should consider moving to NginX ?

Thanks a lot for you help,
Raoul

Additional infos :

About the Apache's config :
    - Apache 2.4.10 (Debian 64 bits) OpenSSL/1.0.1k
    - mpm-event, with mod_headers, mod_ssl, mod_rewrite, mod_proxy, mod_proxy_http
    - The Tomcat's integration is operated with the mod_proxy_ajp

About the Web apps config :
    - Tomcat 8.0.28, with java version "1.7.0_79" (OpenJDK 64 bits)
    - The connector is set to use the AJP/1.3 protocol
    - SSE server based upon Jersey 2.5.1


About the Tomcat logs :
    07-Apr-2019 19:55:19.580 INFO [pool-13-thread-1] org.apache.coyote.AbstractProcessor.setErrorState An error occurred in processing while on a non-container thread. The connection will be closed immediately
    java.io.IOException: Relais brisé (pipe)
    at sun.nio.ch.FileDispatcherImpl.write0(Native Method)
    at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
    [...]
    at org.apache.tomcat.util.net.NioBlockingSelector.write(NioBlockingSelector.java:101)
    [...]
    at org.apache.coyote.ajp.AbstractAjpProcessor.action(AbstractAjpProcessor.java:410)
    [...]
    at org.glassfish.jersey.server.Broadcaster.broadcast(Broadcaster.java:150)
    [...]
    at SAR.DTS.Base.b.o.run(ThreadMajRappels.java:5Cool
    [...]
    at java.lang.Thread.run(Thread.java:745)


    07-Apr-2019 20:10:05.344 INFO [ajp-nio-8015-exec-10] org.apache.catalina.connector.CoyoteAdapter.checkRecycled Encountered a non-recycled response and recycled it forcedly.
    org.apache.catalina.connector.CoyoteAdapter$RecycleRequiredException
    at org.apache.catalina.connector.CoyoteAdapter.checkRecycled(CoyoteAdapter.java:710)
    at org.apache.coyote.ajp.AbstractAjpProcessor.recycle(AbstractAjpProcessor.java:943)
    at org.apache.coyote.ajp.AjpNioProtocol$AjpConnectionHandler.release(AjpNioProtocol.java:163)


About the Apache logs :
    [Sun Apr 07 20:05:22.338619 2019] [proxy_ajp:error] [pid 6573] [client xx.xx.x.xxx:61445] AH00893: dialog to 10.10.12.2:8015 (10.10.12.2) failed, referer: http://yy.yy.yy.yyy/webapp1
    [Sun Apr 07 20:10:05.344774 2019] [proxy_ajp:error] [pid 6573] [client xx.xx.x.xxx:62693] AH00992: ajp_read_header: ajp_ilink_receive failed, referer: http://yy.yy.yy.yyy/webapp1
    [Sun Apr 07 20:10:05.344783 2019] [proxy_ajp:error] [pid 6573] (120006)APR does not understand this error code: [client xx.xx.x.xxx:62693] AH00878: read response failed from 10.10.12.2:8015 (10.10.12.2), referer: http://yy.yy.yy.yyy/webapp1
    [Sun Apr 07 20:10:05.344745 2019] [proxy_ajp:error] [pid 6573] (104)Connection reset by peer: AH01030: ajp_ilink_receive() can't receive header
Back to top
Raoul.Lector



Joined: 10 Apr 2019
Posts: 2
Location: France

PostPosted: Sat 20 Apr '19 19:08    Post subject: Yes, Apache can ! Reply with quote

I found a way to have SSE working in Apache + Tomcat by replacing the AJP connector with the very simple http one :

In Apache config :
Code:
# This statment prevents Apache from redirecting to the local URL.
    # Oddly, it is unnecessary when using the AJP Connector...
    ProxyPreserveHost On
    ProxyPass /webapp1 http://10.10.12.2:8016/webapp1


And in Tomcat config :
Code:
<Connector port="8016" protocol="org.apache.coyote.http11.Http11NioProtocol" proxyPort="80"/>


I don't know if this is the right answer to the initial problem, but it gets me closer to the goal...

For now, I'll try 1) to find (if any) the right config for AJP and 2) to have the http config working with SSL and SSE.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Thu 02 May '19 15:53    Post subject: Reply with quote

What I've don in the past to connect was

Code:

<VirtualHost *:80>
...
<Location />
        ProxyPass ajp://localhost:8009/
        ProxyPassReverse ajp://localhost:8009/
    </Location>+
...
RequestHeader setifempty x-forwarded-for %{REMOTE_ADDR}s

Header add x-forwarded-for %{REMOTE_ADDR}s
</virtualhost>


Sure you can adapt this for your needs.

if you still have a question please ask again.
Back to top


Reply to topic   Topic: Unable to have Server Sent Events working Apache+Tomcat View previous topic :: View next topic
Post new topic   Forum Index -> Other Software