简体   繁体   English

有时我无法使用php java bridge连接到套接字

[英]sometimes I unable to connect to connect to socket using php java bridge

we are using java bridge from PHP application to connect to java application. 我们正在使用PHP应用程序中的Java桥来连接Java应用程序。 But at times, connection get failed to connect. 但是有时,连接无法连接。 Below is the fucntion used to connect. 以下是用于连接的功能。 I am not getting what the issue is. 我没有得到什么问题。 Sometimes it works and sometimes it fails to connect. 有时它可行,有时却无法连接。 Any persistent connection issues or count is set? 是否设置了持久连接问题或计数?

function open() {
            $errno = null;
            $errstr = null;
            $socket = JAVA_PERSISTENT_SERVLET_CONNECTIONS ?
                    pfsockopen("{$this->ssl}{$this->host}", $this->port, $errno, $errstr, 20) :
                    fsockopen("{$this->ssl}{$this->host}", $this->port, $errno, $errstr, 20);
            if (!$socket)
                throw new java_ConnectException("Could not connect to the J2EE server {$this->ssl}{$this->host}:{$this->port}. Please start it. Or define('JAVA_HOSTS', 8080); define('JAVA_SERVLET', false); before including 'Java.inc' and try again. Error message: $errstr ($errno)\n");
            stream_set_timeout($socket, -1);
            return $socket;
        }

     function java_HttpHandler($protocol, $ssl, $host, $port) {
            parent::java_SimpleHttpHandler($protocol, $ssl, $host, $port);
            try {
                $this->socket = $this->open();
            } catch (Exception $e) {
                $cogLink = "http://xxxx.xx.com/products/sup_products.asp?prod_id=81174";
    echo "eeeeerrrr";
    }
}

Any persistent connection issues or count is set? 是否设置了持久连接问题或计数?

Most likely the back-end ran out of handles. 后端很可能用尽了手柄。 Please note that, in order to obtain a persistent connection to a java "continuation", you'll have to send a servlet engine a POST request first. 请注意,为了获得与Java“ continuation”的持久连接,您必须先向Servlet引擎发送POST请求。 After that you can pfsockopen() to the java "continuation" the servlet engine has returned and use protocol request 之后,您可以pfsockopen()到Java“ Continuation”,servlet引擎已返回并使用协议请求

(F p="A"/) (F p =“ A” /)

to recycle- and 回收和

(F p="F"/) (F p =“ F” /)

to put the "continuation" back to the pool. 将“延续”放回池中。

I have checked the Java.inc code and it doesn't contain the code you have posted. 我已经检查了Java.inc代码,它不包含您发布的代码。 Therefore I assume that you have written custom code to emulate Java.inc. 因此,我假设您已经编写了自定义代码来模拟Java.inc。

If so, please make sure to no exceed the bridge thread pool size (20 by default). 如果是这样,请确保不超过桥接线程池的大小(默认为20)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM