簡體   English   中英

ExAws 不適用於生產版本 (Phoenix/Arc/ExAws)

[英]ExAws not working on production release (Phoenix/Arc/ExAws)

我一直在嘗試為頭像創建上傳器,但我遇到了一些問題,代碼在開發人員上運行良好,但在生產版本中,我收到此錯誤:

=SUPERVISOR REPORT==== 8-Jul-2016::22:35:41 ===
     Supervisor: {local,'Elixir.ExAws.Supervisor'}
     Context:    child_terminated
     Reason:     {#{'__exception__' => true,
                    '__struct__' => 'Elixir.Poison.SyntaxError',
                    message => <<"Unexpected token: <">>,
                    token => <<"<">>},
                  [{'Elixir.Poison.Parser','parse!',2,
                       [{file,"lib/poison/parser.ex"},{line,56}]},
                   {'Elixir.Poison','decode!',2,
                       [{file,"lib/poison.ex"},{line,83}]},
                   {'Elixir.ExAws.InstanceMeta',security_credentials,1,
                       [{file,"lib/ex_aws/instance_meta.ex"},{line,16}]},
                   {'Elixir.ExAws.Config.AuthCache',refresh_config,2,
                       [{file,"lib/ex_aws/config/auth_cache.ex"},{line,37}]},
                   {'Elixir.ExAws.Config.AuthCache',handle_call,3,
                       [{file,"lib/ex_aws/config/auth_cache.ex"},{line,27}]},
                   {gen_server,try_handle_call,4,
                       [{file,"gen_server.erl"},{line,615}]},
                   {gen_server,handle_msg,5,
                       [{file,"gen_server.erl"},{line,647}]},
                   {proc_lib,init_p_do_apply,3,
                       [{file,"proc_lib.erl"},{line,247}]}]}
     Offender:   [{pid,<0.2009.0>},
                  {id,'Elixir.ExAws.Config.AuthCache'},
                  {mfargs,
                      {'Elixir.ExAws.Config.AuthCache',start_link,
                          [[{name,'Elixir.ExAws.Config.AuthCache'}]]}},
                  {restart_type,permanent},
                  {shutdown,5000},
                  {child_type,worker}]

22:35:41.624 [error] Ranch protocol #PID<0.2011.0> (:cowboy_protocol) of listener MyApp.Endpoint.HTTP terminated
** (exit) exited in: GenServer.call(ExAws.Config.AuthCache, {:refresh_config, %ExAws.S3{config: %{access_key_id: [{:system, "AWS_ACCESS_KEY_ID"}, :instance_role], host: %{"ap-northeast-1" => 
"s3-ap-northeast-1.amazonaws.com", "ap-southeast-1" => "s3-ap-southeast-1.amazonaws.com", "ap-southeast-2" => "s3-ap-southeast-2.amazonaws.com", "eu-central-1" => "s3-eu-central-1.amazonaws.c
om", "eu-west-1" => "s3-eu-west-1.amazonaws.com", "sa-east-1" => "s3-sa-east-1.amazonaws.com", "us-east-1" => "s3.amazonaws.com", "us-west-1" => "s3-us-west-1.amazonaws.com", "us-west-2" => "
s3-us-west-2.amazonaws.com"}, http_client: ExAws.Request.HTTPoison, json_codec: Poison, region: "us-east-1", scheme: "https://", secret_access_key: [{:system, "AWS_SECRET_ACCESS_KEY"}, :insta
nce_role]}, service: :s3}}, 5000)
    ** (EXIT) an exception was raised:
        ** (Poison.SyntaxError) Unexpected token: <
            (poison) lib/poison/parser.ex:56: Poison.Parser.parse!/2
            (poison) lib/poison.ex:83: Poison.decode!/2
            (ex_aws) lib/ex_aws/instance_meta.ex:16: ExAws.InstanceMeta.security_credentials/1
            (ex_aws) lib/ex_aws/config/auth_cache.ex:37: ExAws.Config.AuthCache.refresh_config/2
            (ex_aws) lib/ex_aws/config/auth_cache.ex:27: ExAws.Config.AuthCache.handle_call/3
            (stdlib) gen_server.erl:615: :gen_server.try_handle_call/4
            (stdlib) gen_server.erl:647: :gen_server.handle_msg/5
            (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3

謝謝。

您的堆棧跟蹤表明 ExAws 使用的一個 dep Poison 未能解碼 json。 如果您檢查進行該調用的模塊( lib/ex_aws/instance_meta.ex ,您可以在此處閱讀),您會發現它與 Amazon 通信以檢查您的憑證。

最可能的情況是您的配置不正確,亞馬遜向您發送了一條錯誤消息,格式為 XML 或 HTML(均以<開頭)。

ExAws 配置取決於環境變量,所以這也可能是它適用於開發而不適用於生產的原因。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM