jingjihui 发表于 2018-12-19 10:33:17

PHP SOAP 客户端访问超时

今天在windows机器上做PHP+SOAP的测试。

服务端环境: windows
客户端环境: windows
服务端和客户端都在一个环境(windows)上。



遇到的问题:服务端能正常的启动,客户端访问服务端的时候,一直显示超时 504错误。

找了很久的资料都没解决,当看到有一篇文章里写到:


我的开发环境是nginx+php,准备作一个soap的实验,soapclient和soapserver都是在我的开发机上,用soapclient访问soapserver的时候,总是返回504错误,相同的代码放到apache+php_module的环境下没有问题。
nginx的错误日志显示,client和server的错误都是fastcgi超时,我一度怀疑是soapserver的问题,soapserver超时不响应,导致了soapclient的超时。
但是我用cli模式执行client,server能正常返回,说明不是soapserver的问题。
用nginx下的client访问apache上的server,正常
用apache下的client访问nginx上的server,正常

我恍然大悟,是不是进程数的问题,先怀疑nginx,后怀疑php-cgi,一查资料,如果用php-cgi -b9000直接器fastcgi的话,同时只能处理一个请求,soapclient和soapserver需要两个进程,soapclient把进程挂 起等soap server返回,但是soapserver等待soapclient释放phpcgi的进程,所以一直都是返回504了。
赶紧打个fpm的补丁,困惑n天的问题解决了。
网上有篇这样的解决办法不过看不明白啊,也不知道好不好用
  来自: http://www.oschina.net/question/1404650_133899
  

  好,看完后,我的情况的和描述的一样,那就照着这个思路去做吧,相信我,是成功的。
  首先: 给PHP开启多个进程,因为默认的是一个进程,windows环境需要类似fpm这样的php进程管理,在网上找了个xxfpm,附件里面有
  

  配置:
  启动fastcgi 一般的配置
D:/php55n/php-cgi.exe -b 127.0.0.1:9000 -c D:/php55n/php.ini
xxfpm D:/php55n/php-cgi.exe -n 2 -p 9000
xxfpm D:/php55n/php-cgi.exe -n 2 -p 9001  上面是三个开启php进程的命令啊。
  

  其次:配置nginx
    #服务端配置
    server {
      listen 80;
      server_name server.com;
      index index.html index.htm index.php;
      root D:/php_workplace/php_soap;
      location / {
            try_files $uri $uri/ /index.php;
      }
      location ~*\.php$ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      }
    }
    #客户端配置
   server {
      listen 81;
      server_name client.com;
      index index.html index.htm index.php;
      root D:/php_workplace/php_soap;
      location / {
            try_files $uri $uri/ /index.php;
      }
      location ~*\.php$ {
            fastcgi_pass 127.0.0.1:9001;
            fastcgi_index index.php;
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      }
    }  

最后:开始测试
测试地址:http://client.com:81/client.php
返回:哈哈,能能访问啦
附件里面有测试代码哦。

附件:http://down.运维网.com/data/2365582

页: [1]
查看完整版本: PHP SOAP 客户端访问超时