Giter Site home page Giter Site logo

Comments (15)

simonask avatar simonask commented on April 28, 2024

As further info, I can add that a dtruss indicates that both bind, listen and accept get called, after which select is called from inside sys_common::net::await (the standard Rust TCP stack).

from hyper.

seanmonstar avatar seanmonstar commented on April 28, 2024

can you run your server with RUST_LOG=hyper=debug?

from hyper.

simonask avatar simonask commented on April 28, 2024

Sure thing:

$ RUST_LOG=hyper=debug target/rust-web
DEBUG:hyper::::server: binding to 127.0.0.1:3000

And that's it… 😦

EDIT: Trying to connect produces no additional output.

from hyper.

seanmonstar avatar seanmonstar commented on April 28, 2024

Hm, it may not even be getting through the TCP layer.

Does the example in the TCP docs work? http://doc.rust-lang.org/std/io/net/tcp/struct.TcpListener.html

from hyper.

simonask avatar simonask commented on April 28, 2024

Hm, it does not! That would suggest a bug in Rust, right?

from hyper.

seanmonstar avatar seanmonstar commented on April 28, 2024

I believe so!

from hyper.

simonask avatar simonask commented on April 28, 2024

Wait a second, my mistake β€” the example from TcpListener does in fact work (as opposed to my telnet invocation skills). The following outputs "Hello, World!" to a connecting telnet instance:

fn main() {
  let listener = TcpListener::bind("127.0.0.1:3000");
  // bind the listener to the specified address
  let mut acceptor = listener.listen();

  fn handle_client(mut stream: TcpStream) {
      stream.write(b"Hello, World!");
  }

  // accept connections and process them, spawning a new tasks for each one
  for stream in acceptor.incoming() {
      match stream {
          Err(e) => { /* connection failed */ }
          Ok(stream) => spawn(proc() {
              // connection succeeded
              handle_client(stream)
          })
      }
  }

  // close the socket server
  drop(acceptor);
}

from hyper.

seanmonstar avatar seanmonstar commented on April 28, 2024

Oh ok. So, the request with curl just says connection refused, but the server doesn't crash nor output any more info?

from hyper.

simonask avatar simonask commented on April 28, 2024

Exactly.

from hyper.

seanmonstar avatar seanmonstar commented on April 28, 2024

So, it should either output DEBUG: incoming stream or an ERROR: connection failed: https://github.com/hyperium/hyper/blob/master/src/server/mod.rs#L103

If it's not getting there, I'm left wondering if the error is happening inside rust-intertwine...

from hyper.

simonask avatar simonask commented on April 28, 2024

As you can probably tell, I'm new to Rust, but I'd be happy to help debugging in whatever ways I can. But I guess first of all: Are you or anyone else able to reproduce this behaviour?

from hyper.

seanmonstar avatar seanmonstar commented on April 28, 2024

I'm able to access the example server with cargo run --example server and can curl it.

from hyper.

simonask avatar simonask commented on April 28, 2024

Alright, I had the same issue with the example, but then I tried curl with a Rails app I had lying around, and it gave the same result. Apparently curl fails on all requests to localhost on my machine. wget and browsers work without issue. I have no clue as to why I'm seeing this behaviour, but the problem seems to be with curl, and neither Rust nor Hyper.

It seems I had the following line in my /etc/hosts:

::1        localhost

which caused curl to attempt an IPv6 connection to localhost, which neither Rust nor Ruby were listening on.

from hyper.

seanmonstar avatar seanmonstar commented on April 28, 2024

Whew. Glad it's worked out.

On Mon, Nov 10, 2014, 11:30 AM Simon Ask Ulsnes [email protected]
wrote:

Alright, I had the same issue with the example, but then I tried curl
with a Rails app I had lying around, and it gave the same result.
Apparently curl fails on all requests to localhost on my machine. wget
and browsers work without issue. I have no clue as to why I'm seeing this
behaviour, but the problem seems to be with curl, and neither Rust nor
Hyper.

It seems I had the following line in my /etc/hosts:

::1 localhost

which caused curl to attempt an IPv6 connection to localhost, which
neither Rust nor Ruby were listening on.

β€”
Reply to this email directly or view it on GitHub
#109 (comment).

from hyper.

simonask avatar simonask commented on April 28, 2024

Me too β€” really, really sorry to have wasted your time!

from hyper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.