无法向同一个 GAE 发出从应用程序引擎获取的请求

问题描述 投票:0回答:0

我在 GAE 上有一个 PHP API,我正在使用 HTML2PDF 并尝试使用 file_get_contents 通过邮件发送 pdf。我的请求来自应用程序引擎实例到同一个应用程序引擎(但可以是另一个实例)。

获取pdf的URL是:“https://example.com/pdf/invoice/user_id/invoice_id/secret_token”; 从浏览器中一切正常,我可以查看并下载文档。

但是如果我正在执行 file_get_contents('https://example.com/pdf/invoice/user_id/invoice_id/secret_token') 我收到错误 500 并且应用程序引擎实例崩溃。使用 cURL 时出现同样的错误。

有卷曲:

错误:服务器错误 服务器遇到错误,无法完成您的请求。请在 30 秒后重试。

使用 file_get_contents:

警告:file_get_contents(https://example.com/pdf/avoir/2020/845/7ac639686c8129258d5752bdf0c3aeb622074c6d89a691a71070f180461c9896):无法打开流:HTTP请求失败! HTTP/1.0 500 内部服务器错误 /workspace/index.php 第 106 行

来自谷歌日志控制台的错误(请求错误 500):

处理此请求的进程意外终止。这可能会导致应用程序的下一个请求使用新的进程。 (错误代码203)

最奇怪的是,我有另一个 pdf 文档的另一个端点,而这个端点工作正常。

我什至尝试替换所有无法正常工作的模板,但仍然遇到相同的错误。 (替换后,唯一不同的是 URL)。

我可以读取模板的 html 缓冲区(如果我之前退出脚本)。问题仅出现在

$pdf->writeHTML($content)
线上。

我尝试了许多使用curl和file_get_contents的用户代理,试图增加超时。但同样的错误。我也尝试过 Postman,一切都很好。

我使用的是 F1 实例,但尝试了 F2 以确保不是内存不足。

(我知道我可以将 html2pdf 直接输出为电子邮件的 base64,但我需要理解为什么它只在某些端点上工作,即使它们是相同的)

非常感谢

编辑:这是来自index.php的代码:

  case 'test-curl':
   102          die(get_data_c('https://example.oa.r.appspot.com/pdf/avoir/2020/826/2330956135b4cd945b1151724c23a13293d207df43b5c435477cb13d4c3258ed.pdf'));
   103      case 'working-test':
   104          die(file_get_contents('https://example.oa.r.appspot.com/pdf/facture/2020/14996/72724f0e57972f3db709de73ec5c0155ba03bddb1ccd437f4d5faa90bfe101c2.pdf'));
   105      case 'test-fgc':
   106          die(file_get_contents('https://example.oa.r.appspot.com/pdf/avoir/2020/845/7ac639686c8129258d5752bdf0c3aeb622074c6d89a691a71070f180461c9896.pdf',0,stream_context_create(["http" => ["timeout" => 20]])));
google-app-engine google-cloud-platform html2pdf
© www.soinside.com 2019 - 2024. All rights reserved.