From: <php...@li...> - 2010-06-25 20:47:03
|
I have recently updated my installation of the JavaBridge and I'm seeing some very strange behavior in my PHP scripts that are using the bridge. I'm hoping that someone else has run into this and can give me a quick answer as to what I can do to fix the issue. The problem is with PHP scripts that are being run from the command line that are using the bridge and taking more than 30s to execute. When the script gets to the point where it should exit it just hangs. Below I've included the source code of a very simple script that I've created to reproduce the issue. When I comment out the line to create the String object the script runs as expected. I'm stumped, I've tried many combinations of ideas and nothing seems to fix the problem. Any help will be appreciated. Thanks, Brian #!/usr/bin/php <?php require_once 'http://192.168.0.198:8080/JavaBridge/java/Java.inc'; $jString = new Java("java.lang.String", "test"); echo "start sleep\n"; sleep(30); echo "sleep finished\n"; echo "start exit\n"; exit(0); echo "exit finished\n"; ?> |
From: <php...@li...> - 2010-06-26 04:51:46
|
I had a hanging problem but at the same time my script was not working. It was because my I hadn't installed JavaBridge and PHP correctly. I just re-installed both, and I didn't have the problem anymore. It could also be something with the exit function, but I don't know JavaBridge well enough to comment what exactly. Sincerely, Sravan Suryadevara On Sat, Jun 26, 2010 at 1:45 AM, < php...@li...> wrote: > I have recently updated my installation of the JavaBridge and I'm seeing > some very strange behavior in my PHP scripts that are using the bridge. > I'm > hoping that someone else has run into this and can give me a quick answer > as > to what I can do to fix the issue. > > The problem is with PHP scripts that are being run from the command line > that are using the bridge and taking more than 30s to execute. When the > script gets to the point where it should exit it just hangs. Below I've > included the source code of a very simple script that I've created to > reproduce the issue. When I comment out the line to create the String > object the script runs as expected. > > I'm stumped, I've tried many combinations of ideas and nothing seems to fix > the problem. Any help will be appreciated. > > Thanks, > Brian > > > > #!/usr/bin/php > <?php > require_once 'http://192.168.0.198:8080/JavaBridge/java/Java.inc'; > > $jString = new Java("java.lang.String", "test"); > > echo "start sleep\n"; > sleep(30); > echo "sleep finished\n"; > > echo "start exit\n"; > exit(0); > echo "exit finished\n"; > > ?> > > ------------------------------------------------------------------------------ > ThinkGeek and WIRED's GeekDad team up for the Ultimate > GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the > lucky parental unit. See the prize list and enter to win: > http://p.sf.net/sfu/thinkgeek-promo > _______________________________________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users > |
From: <php...@li...> - 2010-06-26 11:42:18
|
Hi Brian, > sleep(30); the default tomcat keep-alive timeout is 20000ms. If your script doesn't send any data within 20seconds, tomcat closes the connection. Please change tomcat's server.xml to <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="40000" redirectPort="8443" /> (there's no separate keepAliveTimeout; Tomcat uses the connectionTimeout for the keep-alive as well) The hanging at the end of the script is another problem. PHP/Java Bridge 6.0 uses HTTP/1.1 chunked connections, which require a shutdown sequence. From the current Java.inc: for ($this->res=$this->fread(10); strlen($this->res) < 10; $this->res.=$this->fread(10-strlen($this->res))); The "10" is the <F t="E"/>, which is okay. But I should have checked that the connection is still alive. Or simply replace the for loop with fread($sock, 10), as tomcat won't send the 10 bytes one-after-the-other. Thank you very much for reporting this issue. Regards, Jost Bökemeier |
From: <php...@li...> - 2010-06-26 12:29:29
|
Great, thanks for the quick response. I've updated my tomcat timeout and everything seems to be working well enough now. Thanks for the help, Brian On Sat, Jun 26, 2010 at 7:42 AM, < php...@li...> wrote: > Hi Brian, > > > sleep(30); > > the default tomcat keep-alive timeout is 20000ms. If your script > doesn't send any data within 20seconds, tomcat closes the connection. > > Please change tomcat's server.xml to > > <Connector port="8080" protocol="HTTP/1.1" > connectionTimeout="40000" > redirectPort="8443" /> > > (there's no separate keepAliveTimeout; Tomcat uses the > connectionTimeout for the keep-alive as well) > > The hanging at the end of the script is another problem. PHP/Java > Bridge 6.0 uses HTTP/1.1 chunked connections, which require a shutdown > sequence. From the current Java.inc: > > for ($this->res=$this->fread(10); strlen($this->res) < 10; > $this->res.=$this->fread(10-strlen($this->res))); > > The "10" is the <F t="E"/>, which is okay. But I should have checked > that the connection is still alive. Or simply replace the for loop > with fread($sock, 10), as tomcat won't send the 10 bytes > one-after-the-other. > > > Thank you very much for reporting this issue. > > > Regards, > Jost Bökemeier > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users > |
From: <php...@li...> - 2010-06-26 12:57:42
|
Hi Brian, you should probably keep using PHP/Java Bridge version 5.x instead. If it is true that the timeout cannot be configured reliably ( see http://marc.info/?l=tomcat-dev&m=115956945015246&w=3 ), the PHP/Java Bridge version 6 becomes useless, until tomcat supports a reliable, persistent communication channel. For example WebSockets. I will mark PHP/Java Bridge version 6 as "experimental" and will check the tomcat 6 source code. Thanks again for reporting this issue! Regards, Jost Bökemeier |
From: <php...@li...> - 2010-06-26 15:14:47
|
> I will mark PHP/Java Bridge version 6 as "experimental" Done. Current stable download is PHP/Java Bridge 5.5.4.1 The next version, PHP/Java Bridge 6.2.1, will contain the following changes: * Use the WebSocket protocol instead of HTTP/1.1 chunked connection * Dropped support for all application servers which do not support the WebSocket protocol. This means: Jetty 7 only. * JSR 223 script engine improvements: FastCGI instead of CGI and getInvocablePhpScriptEngine() w/o the URI parameter for local script invocation and implementation of the Compilable interface. Regards, Jost Bökemeier |
From: <php...@li...> - 2010-06-27 10:58:58
|
WebSockets specification incudes an "idle timeout", which makes it useless for our purposes, too. -- How do they want us to re-connect to the same back end after a timeout? I will simply revert the PhpJavaServlet code to version 5.5. and keep it. However, the standalone JavaBridge.jar runner will continue to use chunked HTTP/1.1 connections, as it doesn't have this timeout problem. The next version, PHP/Java Bridge 6.2.1, will contain the following changes: * Revert changes to PhpJavaServlet and Java.inc. * JSR 223 script engine improvements: FastCGI instead of CGI and getInvocablePhpScriptEngine() w/o the URI parameter for local script invocation and implementation of the Compilable interface. Regards, Jost Bökemeier |
From: <php...@li...> - 2010-06-27 11:27:53
|
> WebSockets specification incudes an "idle timeout" Correction: This "idle timeout" is a Jetty-specific implementation problem inherited from the HTTP connection parameter. The spec doesn't mention anything about a server timeout: "At any time, the server may decide to terminate the WebSocket connection ..." But we should wait until the servlet spec includes web socket. Regards, Jost Bökemeier |
From: <php...@li...> - 2010-07-04 11:28:29
|
> The next version, PHP/Java Bridge 6.2.1, will contain the following > changes: > > * Revert changes to PhpJavaServlet and Java.inc. Done. > * JSR 223 script engine improvements: FastCGI instead of CGI and > getInvocablePhpScriptEngine() w/o the URI parameter for local script > invocation and implementation of the Compilable interface. Done. The EngineFactory and the http script engines are gone. The only remaining script engines are the PhpScriptEngine, InvocablePhpScriptEngine and InteractivePhpScriptEngine. There were two examples using the http script engines. The jsr223.jsp has been replaced by a simple jsp:forward, the other example has been removed. Use the InvocablePhpScriptEngine and register it with the servlet shutdown hook if you need this functionality in a servlet. I have added JUnit test cases for the PhpScriptEngine. Before we make any release we should convert the old Makefile scripts from tests.php5 and tests.jsr223 to JUnit test cases. Known bugs so far: 1. The PHP FastCGI implementation doesn't pass the exit() status, see http://svn.php.net/viewvc/php/php-src/trunk/sapi/cgi/fastcgi.c?revision=296679&view=markup&sortby=date lines 1083-1087. 2. JSR223 compile() has no way to specify the compilation output file or directory.(!) The test cases use ((java.io.FileFilter)scriptEngine).accept(File); to pass it to the ScriptEngine. Regards, Jost Bökemeier |