Laravel 7-什么可能导致间歇性419错误?

发布于 2025-02-08 08:55:38 字数 1616 浏览 0 评论 0原文

我有一个网站运行,Laravel 7在3个应用程序服务器中连接到1个数据库服务器。

3个应用程序服务器已安装了已安装。会话驱动程序被备忘。而且,我已经在Laravel配置中添加了3个服务器,以用于Memcached。

config/cache.php

...
'memcached' => [
    'driver'  => 'memcached',
    'persistent_id' => 'memcached_pool_id',
    'options' => [
        // some nicer default options
        // - nicer TCP options
        Memcached::OPT_TCP_NODELAY => TRUE,
        Memcached::OPT_NO_BLOCK => FALSE,
        // - timeouts
        Memcached::OPT_CONNECT_TIMEOUT => 2000,    // ms
        Memcached::OPT_POLL_TIMEOUT => 2000,       // ms
        Memcached::OPT_RECV_TIMEOUT => 750 * 1000, // us
        Memcached::OPT_SEND_TIMEOUT => 750 * 1000, // us
        // - better failover
        Memcached::OPT_DISTRIBUTION => Memcached::DISTRIBUTION_CONSISTENT,
        Memcached::OPT_LIBKETAMA_COMPATIBLE => TRUE,
        Memcached::OPT_RETRY_TIMEOUT => 2,
        Memcached::OPT_SERVER_FAILURE_LIMIT => 1,
        Memcached::OPT_AUTO_EJECT_HOSTS => TRUE,
    ],
    'servers' => [
        [
            'host' => 'ip1',
            'port' => '11211',
            'weight' => 100,
        ],
        [
            'host' => 'ip2',
            'port' => '11211',
            'weight' => 100,
        ],
        [
            'host' => 'ip3',
            'port' => '11211',
            'weight' => 100,
        ]
    ]
]

verifycsrftkoken中间件处于活动状态,大多数时候一切都起作用,但是有些请求会抛出419个错误(随机),即使它们发送了适当的cookie(laravel session和csrf token)和Memcached Store具有会话数据。

发生错误时,可能会在失败之前或之后成功请求。

还有其他可能导致这个问题的吗?

I have a website running with Laravel 7 in 3 app servers connected to 1 database server.

The 3 app servers have memcached installed. The session driver is memcached. And I've added the 3 servers in the Laravel configuration for memcached.

config/cache.php

...
'memcached' => [
    'driver'  => 'memcached',
    'persistent_id' => 'memcached_pool_id',
    'options' => [
        // some nicer default options
        // - nicer TCP options
        Memcached::OPT_TCP_NODELAY => TRUE,
        Memcached::OPT_NO_BLOCK => FALSE,
        // - timeouts
        Memcached::OPT_CONNECT_TIMEOUT => 2000,    // ms
        Memcached::OPT_POLL_TIMEOUT => 2000,       // ms
        Memcached::OPT_RECV_TIMEOUT => 750 * 1000, // us
        Memcached::OPT_SEND_TIMEOUT => 750 * 1000, // us
        // - better failover
        Memcached::OPT_DISTRIBUTION => Memcached::DISTRIBUTION_CONSISTENT,
        Memcached::OPT_LIBKETAMA_COMPATIBLE => TRUE,
        Memcached::OPT_RETRY_TIMEOUT => 2,
        Memcached::OPT_SERVER_FAILURE_LIMIT => 1,
        Memcached::OPT_AUTO_EJECT_HOSTS => TRUE,
    ],
    'servers' => [
        [
            'host' => 'ip1',
            'port' => '11211',
            'weight' => 100,
        ],
        [
            'host' => 'ip2',
            'port' => '11211',
            'weight' => 100,
        ],
        [
            'host' => 'ip3',
            'port' => '11211',
            'weight' => 100,
        ]
    ]
]

The VerifyCsrfToken middleware is active, and most of the time everything works, but there are some requests that throw a 419 error (randomly), even though they send the appropriate cookies (laravel session and csrf token), and the memcached store has the session data.

When the error occurs, there might've been successful requests before or after the failure.

Is there anything else that could be causing this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文