php - Zend/Apache2 : Getting 302 Found when requesting url several times

标签 php mysql api zend-framework apache2

我正在使用 Zend 框架编写REST API
多次调用 url 时(例如每秒 1 个请求 1000 次),在大约 0.2% 的情况下而不是得到 200 OK作为响应,我得到 302 Found - 所以重定向到另一个页面。
这是整个服务器响应:

302 Found Date: Mon, 04 Mar 2013 11:56:04 GMT
Server: Apache/2.2.17 (Ubuntu)
X-Powered-By: PHP/5.3.5-1ubuntu7.11
Set-Cookie: PHPSESSID=ui9r8jqa63dbom8osknso6eea5; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Location: /de/default/index/index/error/500
Vary: Accept-Encoding
Content-Length: 0
Content-Type: text/html; charset=utf-8

因此 Zend 重定向到 error 500(内部服务器错误)页面。问题是为什么 - 我就是想不通...
调用的 php 页面将一行插入 MySQL 数据库并返回一个 JSON 字符串 - 仅此而已。

Apache2 打开了大约 20 个并发连接 并且服务器负载为 <<1 所以我真的不明白为什么请求会导致问题。

我知道这是一个很难远程诊断的问题,但非常欢迎提出解决此问题的良好猜测和建议!谢谢。

这是@chris 请求的 apache vhost 配置:

<IfModule mod_ssl.c>
<VirtualHost mydomain.tld:443>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    ServerName www.mydomain.tld
    ServerAlias mydomain.tld *.mydomain.tld
    <Directory />
        Options FollowSymLinks
        AllowOverride All
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/ssl_access.log combined

#   RewriteLog "/var/log/htaccess.log"
#   RewriteLogLevel 5

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

    #   SSL Engine Switch:
    #   Enable/Disable SSL for this virtual host.
    SSLEngine on
    SSLOptions +StrictRequire
    SSLCertificateFile /etc/apache2/ssl/cert_2013_2014.crt
    SSLCertificateKeyFile /etc/apache2/ssl/www.mydomain.tld.key
    SSLCACertificateFile /etc/apache2/ssl/intermediate.crt

</VirtualHost>
</IfModule>

最佳答案

这对我来说看起来非常简单直接。这是一个 302 重定向,我想不出 ZF 中有什么可以自行重定向的;特别是不要出现 500 错误页面。 500 错误(内部服务器错误)必须始终返回 500 错误并且永远不应该是 302 重定向。所以你在这里有点幸运,因为你的 RETS API 中必须有一些错误处理,这会导致在某处重定向(而不是常规错误页面)。

在您的代码中搜索重定向。它可以使用 ZF 重定向器帮助程序(在 Controller 内)或手动(在任何地方)使用 header() 和 exit() 来完成。当您发现重定向时,要么使用 debug_backtrace 显示(退出),要么将其转储到日志文件中。并修复返回码或错误处理方式。

关于php - Zend/Apache2 : Getting 302 Found when requesting url several times,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15201741/

相关文章:

javascript - 在 youtube api 中检测播放事件

.net - Outlook.com的API

ruby-on-rails - 如何通过 Grape API 获取路由

PHP mySQL 更新行函数未按预期工作 - SQLSTATE[42000] : Syntax error or access violation: 1064

php - 构建一个用于获取菜单树的数组 - PHP

php -/* */注释 block 的 Netbeans 宏命令

mysql8.0.22设置默认值DATE_FORMAT(sysdate() ,'%Y%m%d' )错误

javascript - 按下按钮时从 sql &php 获取行内容,即使调用 id

php - 如何在 ubuntu 上将 MySQL 主机设置为 'localhost' 以外的其他值?

MySql 将列中的所有字段更新为其默认值