【问题标题】:start erlang/elixir on a defined interface ip address在定义的接口 IP 地址上启动 erlang/elixir
【发布时间】:2017-05-29 02:55:36
【问题描述】:

我正在使用 elixir 对我机器上的主机进行一些 XMLRPC 查询,该主机只接受来自 127.0.x.y 的调用,其中 x 和 y 可以配置,但 ip 不能是 127.0.0.1。

除非我添加标志--interface 127.0.x.y,否则对该主机的简单curl 请求将失败。

如何使用不同于 127.0.0.1 的给定接口 ip 启动我的 elixir 应用程序?

如果有帮助的话,我用来发送请求的库是 HTTPoison。

【问题讨论】:

  • 这是否有效(使用正确的 URL 和 IP):HTTPoison.get "http://localhost:8000/", [], [hackney: [connect_options: [ip: {127, 0, 0, 1}]]]?
  • 好的,谢谢!我花了一整天的时间在hackney 文档和源代码上找到该选项...如果您将评论转换为答案,我将接受它

标签: networking erlang elixir httpoison


【解决方案1】:

您可以将connect_options 中的ip 传递给hackneyhackneyconnect_options 直接传递给gen_tcp,后者接受ip

HTTPoison.get("http://...", [], [hackney: [connect_options: [ip: {127, 0, 0, 1}]]])

【讨论】:

    猜你喜欢
    • 2010-11-17
    • 2021-01-20
    • 2011-01-18
    • 2016-06-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-04
    • 2021-06-28
    相关资源
    最近更新 更多