Stephen
Stephen

Reputation: 3992

How to connect to a phoneix framework app locally by telnet?

I would like to use telnet to test my phoenix app, but it shows Connection closed by foreign host. very quickly and telnet exits.

$ telnet 127.0.0.1 4000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.

The phoenix app is a very simple one without any extra configuration. How can I connect to it with telnet?

Upvotes: 4

Views: 182

Answers (1)

Virviil
Virviil

Reputation: 632

Phoenix uses Cowboy as underlying webserver. It has different timeout options, but the one we need is request_timeout.

It defaults to 5_000 (in milliseconds) and can be changed inside configuration like this:

config :my_app, MyApp.Endpoint,
  http: [
    port: ...,
    ...
    protocol_options: [
      request_timeout: 60000 # minute here - for example
    ]
  ]

Now, you have a minute to type your:

GET /

inside telnet CLI

Upvotes: 6

Related Questions