belgattitude / php-java-bridge

Soluble PHP/Java bridge server (unofficial fork)
Other
46 stars 10 forks source link

php.java.fastcgi.ConnectionException #62

Closed craone closed 5 years ago

craone commented 5 years ago

php version 7.3.5 OS centos amd64 php-java-bridge version 7.2.1 After a period of use, the error occurs

13-May-2019 03:01:46.262 SEVERE [http-nio-8080-exec-12] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [PhpCGIServlet] in context with path [/php_project] threw exception
 php.java.fastcgi.ConnectionException
    at php.java.fastcgi.FCGIInputStream.read(FCGIInputStream.java:31)
    at php.java.fastcgi.FCGIHeaderParser.parseBody(FCGIHeaderParser.java:82)
    at php.java.servlet.fastcgi.FastCGIServlet.doExecute(FastCGIServlet.java:424)
    at php.java.servlet.fastcgi.FastCGIServlet.execute(FastCGIServlet.java:516)
    at php.java.servlet.fastcgi.FastCGIServlet.handle(FastCGIServlet.java:527)
    at php.java.servlet.fastcgi.FastCGIServlet.doGet(FastCGIServlet.java:555)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at php.java.servlet.PhpCGIFilter.doFilter(PhpCGIFilter.java:126)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:808)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Protocol error
    at php.java.fastcgi.FCGIInputStream.doRead(FCGIInputStream.java:56)
    at php.java.fastcgi.FCGIInputStream.read(FCGIInputStream.java:29)
    ... 32 more
belgattitude commented 5 years ago

Hey just a quick reply, cause I'm in a rush for the next 3 weeks. and not sure if i can dig into it for now.

First I've never had that error. at least with ubuntu ondrej ppa. but I guess it's equivalent. Our servers have been upgraded to latest 7.3 recently and till now it's fine.

Second. Intuitively. the error looks to be with phpfpm. checks those 3 things

  1. php error log to see if something really bad happened. and check for dumps

  2. check for maximum connections. Are they well released ?

  3. check the number of fpm processes running.

if I have time ill have a look but I need more info like.

which way do you use the bridge. java toward php or the other way. the client you use.... and whatever could help me

craone commented 5 years ago

I am use the bridge.java in tomcat. After restarting TOMCAT, these days are running normally. Reappear again, I will checks phpfpm on your opinion. thanks help.

craone commented 5 years ago

error appear again. php error log is empty. and i 'am not install php-fpm.

[root@localhost ~]# ps -elf | grep php
0 S tomcat   11233 11173  0  80   0 -  2920 pipe_w May16 ?        00:00:00 /bin/sh /opt/tomcat/webapps/test/WEB-INF/cgi/launcher.sh /usr/bin/php-cgi -b 127.0.0.1:9668 -d session.save_path='/opt/tomcat/temp' -d java.os_arch_dir='/opt/tomcat/webapps/test/WEB-INF/cgi/amd64-linux' -d java.pear_dir='/opt/tomcat/webapps/test/WEB-INF/pear' -d java.web_inf_dir='/opt/tomcat/webapps/test/WEB-INF' -C -d java.session=On -d display_errors=Off -d log_errors=On -d java.persistent_servlet_connections=On -d allow_url_include=On
0 S tomcat   11234 11233  0  80   0 - 84163 do_wai May16 ?        00:00:00 /usr/bin/php-cgi -b 127.0.0.1:9668 -d session.save_path='/opt/tomcat/temp' -d java.os_arch_dir='/opt/tomcat/webapps/test/WEB-INF/cgi/amd64-linux' -d java.pear_dir='/opt/tomcat/webapps/test/WEB-INF/pear' -d java.web_inf_dir='/opt/tomcat/webapps/test/WEB-INF' -C -d java.session=On -d display_errors=Off -d log_errors=On -d java.persistent_servlet_connections=On -d allow_url_include=On
1 S tomcat   11236 11234  0  80   0 - 84301 sk_wai May16 ?        00:00:01 /usr/bin/php-cgi -b 127.0.0.1:9668 -d session.save_path='/opt/tomcat/temp' -d java.os_arch_dir='/opt/tomcat/webapps/test/WEB-INF/cgi/amd64-linux' -d java.pear_dir='/opt/tomcat/webapps/test/WEB-INF/pear' -d java.web_inf_dir='/opt/tomcat/webapps/test/WEB-INF' -C -d java.session=On -d display_errors=Off -d log_errors=On -d java.persistent_servlet_connections=On -d allow_url_include=On
1 S tomcat   11237 11234  0  80   0 - 84235 sk_wai May16 ?        00:00:01 /usr/bin/php-cgi -b 127.0.0.1:9668 -d session.save_path='/opt/tomcat/temp' -d java.os_arch_dir='/opt/tomcat/webapps/test/WEB-INF/cgi/amd64-linux' -d java.pear_dir='/opt/tomcat/webapps/test/WEB-INF/pear' -d java.web_inf_dir='/opt/tomcat/webapps/test/WEB-INF' -C -d java.session=On -d display_errors=Off -d log_errors=On -d java.persistent_servlet_connections=On -d allow_url_include=On
1 S tomcat   11238 11234  0  80   0 - 87852 hrtime May16 ?        00:00:04 /usr/bin/php-cgi -b 127.0.0.1:9668 -d session.save_path='/opt/tomcat/temp' -d java.os_arch_dir='/opt/tomcat/webapps/test/WEB-INF/cgi/amd64-linux' -d java.pear_dir='/opt/tomcat/webapps/test/WEB-INF/pear' -d java.web_inf_dir='/opt/tomcat/webapps/test/WEB-INF' -C -d java.session=On -d display_errors=Off -d log_errors=On -d java.persistent_servlet_connections=On -d allow_url_include=On
1 S tomcat   14303 11234  0  80   0 - 84235 sk_wai 05:40 ?        00:00:00 /usr/bin/php-cgi -b 127.0.0.1:9668 -d session.save_path='/opt/tomcat/temp' -d java.os_arch_dir='/opt/tomcat/webapps/test/WEB-INF/cgi/amd64-linux' -d java.pear_dir='/opt/tomcat/webapps/test/WEB-INF/pear' -d java.web_inf_dir='/opt/tomcat/webapps/test/WEB-INF' -C -d java.session=On -d display_errors=Off -d log_errors=On -d java.persistent_servlet_connections=On -d allow_url_include=On
1 S tomcat   14391 11234  0  80   0 - 84163 inet_c 06:11 ?        00:00:00 /usr/bin/php-cgi -b 127.0.0.1:9668 -d session.save_path='/opt/tomcat/temp' -d java.os_arch_dir='/opt/tomcat/webapps/test/WEB-INF/cgi/amd64-linux' -d java.pear_dir='/opt/tomcat/webapps/test/WEB-INF/pear' -d java.web_inf_dir='/opt/tomcat/webapps/test/WEB-INF' -C -d java.session=On -d display_errors=Off -d log_errors=On -d java.persistent_servlet_connections=On -d allow_url_include=On
0 S root     14548 14495  0  80   0 - 28178 pipe_w 07:45 pts/0    00:00:00 grep --color=auto php
belgattitude commented 5 years ago

could you check my last question?

craone commented 5 years ago

Did not install php-fpm, only installed php73,
ps -elf | grep php find 6 php-cgi processes running.

belgattitude commented 5 years ago

Did not install php-fpm, only installed php73, ps -elf | grep php find 6 php-cgi processes running.

Yes I was wrong ;), I meant php-cgi... ~can you give me the path of the binary (is it the internal one, or the system wide) ?~ Edit: I got it ;)

2 questions that will help me:

craone commented 5 years ago

A pure PHP project that copies JAVA, META-INF, and WEB-INF directories into the PHP project. The web container is tomcat 8.5.40. The browser is chrome 70.0.3538.110 Now I'm trying php-fpm and hope it works well.

belgattitude commented 5 years ago

@craone, rush is over I'm back again ;)

Now I think I understand better your concerns. Correct me if I'm wrong, but you are trying to run php on tomcat. It's not clear to me why you choose to do it, but php-fpm (+apache or nginx) is the way to go.

php-java-bridge is by no mean a replacement for that. I tried to explain few use cases here:

https://docs.soluble.io/soluble-japha/

To understand better.... you will have tomcat+bridge AND regular apache/nginx/php-fpm servers running side by side on different ports (apache on 80 and tomcat 8080 firewalled).

With this setup you can use java libraries directly from your php code, without scarifying too much the performance (no system calls).

You can have more info here:

I don't advocate to use the bridge... but it's pretty simple and fast, depending on the project you're working on of course

craone commented 5 years ago

As you said the bridge is pretty simple and fast. Finally, I used php-fpm+nginx :( . I can't solve this problem.
Thank you very much for taking time out of your rush to help me.

rnkhouse commented 5 years ago

@craone I am getting exactly the same error using docker image.

Did you solve the issue yet?

craone commented 5 years ago

@rnkhouse no, I used php-fpm+nginx . I can't solve this problem. ; (