我正在努力尋找有關讓鳳凰城(和牛仔和牧場爲此)聽IPv4和IPv6的信息。如何讓Phoenix收聽IPv6?
我在使用Ubuntu 16.04的VPS上運行。它具有IPv4和IPv6地址。 當運行netstat -tulpn
時,它顯示beam
僅偵聽IPv4,並且在Phoenix配置中指定了端口。 而其他進程,如epmd
,能夠偵聽IPv4和IPv6。
我試過在我的config.exs
中指定一個像"::4000"
這樣的端口,但是由於無法解析爲整數而崩潰。
有人能指出我正確的方向嗎?我需要以某種方式添加一個自定義的牛仔聽衆嗎?
我寧願不必在前面運行Nginx來監聽IPv6流量。
配置我想:
config :my_app, MyApp.Endpoint,
http: [port: "[::]:4000"]
堆棧跟蹤(看起來像鳳凰只期待一個整數端口):
** (Mix) Could not start application my_app: MyApp.start(:normal, []) returned an error: shutdown: failed to start child: MyApp.Endpoint
** (EXIT) shutdown: failed to start child: Phoenix.Endpoint.Server
** (EXIT) an exception was raised:
** (ArgumentError) argument error
:erlang.binary_to_integer("[::]:4000")
(phoenix) lib/phoenix/endpoint/server.ex:32: Phoenix.Endpoint.Server.to_port/1
(phoenix) lib/phoenix/endpoint/server.ex:28: Phoenix.Endpoint.Server.default/3
(phoenix) lib/phoenix/endpoint/server.ex:17: anonymous fn/5 in Phoenix.Endpoint.Server.init/1
(elixir) lib/enum.ex:1623: Enum."-reduce/3-lists^foldl/2-0-"/3
(phoenix) lib/phoenix/endpoint/server.ex:15: Phoenix.Endpoint.Server.init/1
(stdlib) supervisor.erl:294: :supervisor.init/1
(stdlib) gen_server.erl:328: :gen_server.init_it/6
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
而且這是鳳凰{:phoenix, "~> 1.2.0"}
和牛仔{:cowboy, "~> 1.0"}
你嘗試過類似'[::]:4000'嗎?參見[RFC 5952,第6節,關於合併IPv6地址和端口號的注意事項](https://tools.ietf.org/html/rfc5952#section-6)。 –
感謝您的建議,但它不能解析一個整數。我會用包含堆棧跟蹤的更多信息更新問題。 – TalkLittle
首先,應用程序必須支持IPv6。看來這個應用程序沒有。聯繫其開發人員。 –