RejectedSoftware Forums

Sign up

HTTP server stopped working(?)

It seems like, after upgrading from 0.7.16 to 0.7.18 (I think), my simple webserver has stopped working. It is coded like this:

    auto settings = new HTTPServerSettings;
    settings.port = 9000;
    settings.bindAddresses = ["127.0.0.1"];
    
    auto router = new URLRouter;
    router.get("/", serveStaticFile("./ui/index.html"));
    router.get("/socket", handleWebSockets(&connectionHandler));
    router.get("*", serveStaticFiles("./ui/"));
    router.get("*", serveStaticFiles("./build/autogen/ui/"));
    listenHTTP(settings, router);

When I try to connect to 127.0.0.1 with curl, I get the following

$ curl -v localhost:9000
* Rebuilt URL to: localhost:9000/
* Adding handle: conn: 0x1500ab0
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x1500ab0) send_pipe: 1, recv_pipe: 0
* About to connect() to localhost port 9000 (#0)
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 9000 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.32.0
> Host: localhost:9000
> Accept: */*
> 
< HTTP/1.1 200 OK
* Server vibe.d/0.7.18 is not blacklisted
< Server: vibe.d/0.7.18
< Date: Sat, 18 Jan 2014 21:19:17 GMT
< Keep-Alive: timeout=10
< Last-Modified: Fri, 29 Nov 2013 20:57:01 GMT
< Etag: "B0E3F852E9AFA7F3C57AB03825B9235E"
< Expires: Sun, 19 Jan 2014 21:19:17 GMT
< Cache-Control: max-age=86400
< Content-Type: text/html
< Content-Length: 867
< 

and it stalls there.. Seems like it is waiting for more data. This is exactly the same as if I try to open this address with chrome/firefox. They sit there waiting for data. If I select a file that does not exist with the URL given to e.g. curl, it fails with a 404, file not found.

This is the 'verbose4' log from Vibed

Timer event true/true
Timer event true/false
connect callback
accept
FD: 31
accepted 31
running task
start task (fd 31).
add timeout event with 10/0
wait for data
accept
FD: -1
accepted -1
handled incoming connections...
socket 31 read event!
 -> timeout = false
reading request..
HTTP server reading status line
evbuffer_read 16 bytes (fd 31)
 .. got 16 bytes
read data
--------------------
HTTP server request:
--------------------
GET / HTTP/1.1
evbuffer_read 25 bytes (fd 31)
 .. got 25 bytes
read data
evbuffer_read 22 bytes (fd 31)
 .. got 22 bytes
read data
evbuffer_read 13 bytes (fd 31)
 .. got 13 bytes
read data
evbuffer_read 2 bytes (fd 31)
 .. got 2 bytes
read data
Date: Sat, 18 Jan 2014 21:20:58 GMT
User-Agent: curl/7.32.0
Host: localhost:9000
Accept: */*
--------------------
Got request header.
persist: true
handle request (body 0)
route match: / -> GET /
opened file ./ui/index.html with 867 bytes as 32
---------------------
HTTP server response:
---------------------
HTTP/1.1 200 OK
Server: vibe.d/0.7.18
Date: Sat, 18 Jan 2014 21:20:58 GMT
Keep-Alive: timeout=10
Last-Modified: Fri, 29 Nov 2013 20:57:01 GMT
Etag: "B0E3F852E9AFA7F3C57AB03825B9235E"
Expires: Sun, 19 Jan 2014 21:20:58 GMT
Cache-Control: max-age=86400
Content-Type: text/html
Content-Length: 867
---------------------
evbuffer_add (fd 31): 307 B
bufferevent_flush
writing stream 0 867
socket 31 write event (false)!
Timer event true/true
Creating new fiber...
Timer event true/false
Timer event true/true
Timer event true/false
Timer event true/true
Timer event true/false

and then no more activity except the Timer event strings.. Please help

Re: HTTP server stopped working(?)

Am 18.01.2014 22:22, schrieb Øivind Loe:

It seems like, after upgrading from 0.7.16 to 0.7.18 (I think), my simple webserver has stopped working. (...)

How does vibe.d master behave there? The log output looks like it's
stuck reading the file from disk (or yield()ing). There have been a
few issues with yield that are now fixed, maybe those are somehow
responsible for this (although it doesn't seem very likely).

Re: HTTP server stopped working(?)

On Tue, 21 Jan 2014 14:13:22 +0100, Sönke Ludwig wrote:

Am 18.01.2014 22:22, schrieb Øivind Loe:

It seems like, after upgrading from 0.7.16 to 0.7.18 (I think), my simple webserver has stopped working. (...)

How does vibe.d master behave there? The log output looks like it's
stuck reading the file from disk (or yield()ing). There have been a
few issues with yield that are now fixed, maybe those are somehow
responsible for this (although it doesn't seem very likely).

Did not help to move to master.. When I abort the request, there is some more input from vibed.. See the last lines:

--------------------
Got request header.
persist: true
handle request (body 0)
route match: / -> GET /
opened file ./ui/index.html with 867 bytes as 34
---------------------
HTTP server response:
---------------------
HTTP/1.1 200 OK
Content-Encoding: gzip
Server: vibe.d/0.7.18
Date: Fri, 24 Jan 2014 02:35:31 GMT
Keep-Alive: timeout=10
Last-Modified: Fri, 29 Nov 2013 20:57:01 GMT
Etag: "B0E3F852E9AFA7F3C57AB03825B9235E"
Expires: Sat, 25 Jan 2014 02:35:31 GMT
Cache-Control: max-age=86400
Content-Type: text/html
Transfer-Encoding: chunked
---------------------
evbuffer_add (fd 32): 338 B
bufferevent_flush
socket 32 write event (false)!
Timer event true/true
Creating new fiber...
Timer event true/false
Timer event true/true
Timer event true/false
Timer event true/true
Timer event true/false
Timer event true/true
Timer event true/false
Timer event true/true
Timer event true/false
Timer event true/true
Timer event true/false
Timer event true/true
Timer event true/false
Timer event true/true
Timer event true/false
Timer event true/true
Timer event true/false
Socket event on fd 32: 17 (7FBFDC003E88 vs 7FBFDC003E88)
Connection was closed (fd 32).
Timer event true/true
Timer event true/false
data wait timeout
 -> timeout = true
Client didn't send the initial request in a timely manner. Closing connection.
task out (fd 33).
Closing socket 33...
...socket 33 closed.
task finished.
Timer event true/true
Timer event true/false

Re: HTTP server stopped working(?)

--------------------
Got request header.
persist: true
handle request (body 0)
route match: / -> GET /
opened file ./ui/index.html with 867 bytes as 34
---------------------
HTTP server response:
---------------------
HTTP/1.1 200 OK
Content-Encoding: gzip

Content-Encoding: gzip should not be there by default for vibe.d master. Are you sure you get the right vibe.d version?

Anyways, I could not reproduce this issue. I've tested with a 867 bytes long index.html and it downloaded without any issues. I'm on Mac OS 10.9.1, DMD 2.064.2.

Re: HTTP server stopped working(?)

On Fri, 24 Jan 2014 12:46:42 GMT, Sükriye Ludwig wrote:

--------------------
Got request header.
persist: true
handle request (body 0)
route match: / -> GET /
opened file ./ui/index.html with 867 bytes as 34
---------------------
HTTP server response:
---------------------
HTTP/1.1 200 OK
Content-Encoding: gzip

Content-Encoding: gzip should not be there by default for vibe.d master. Are you sure you get the right vibe.d version?

Anyways, I could not reproduce this issue. I've tested with a 867 bytes long index.html and it downloaded without any issues. I'm on Mac OS 10.9.1, DMD 2.064.2.

Thanks for trying it out. I made a mistake though.. Was not actually running on master. With master, I get the following compile errors:

/usr/include/dmd/phobos/std/traits.d(2573): Error: template instance isStaticArray!(__T23RepresentationTypeTupleTS3std9container54__T5ArrayTS4vibe4core7drivers9libevent212TimeoutEntryZ5Array7PayloadZ) does not match template declaration isStaticArray(T)
/usr/include/dmd/phobos/std/traits.d(2583): Error: template instance isPointer!(__T23RepresentationTypeTupleTS3std9container54__T5ArrayTS4vibe4core7drivers9libevent212TimeoutEntryZ5Array7PayloadZ) does not match template declaration isPointer(T)
/usr/include/dmd/phobos/std/traits.d(2583): Error: template instance isDynamicArray!(__T23RepresentationTypeTupleTS3std9container54__T5ArrayTS4vibe4core7drivers9libevent212TimeoutEntryZ5Array7PayloadZ) does not match template declaration isDynamicArray(T)
/usr/include/dmd/phobos/std/traits.d(2584): Error: template instance isAssociativeArray!(__T23RepresentationTypeTupleTS3std9container54__T5ArrayTS4vibe4core7drivers9libevent212TimeoutEntryZ5Array7PayloadZ) does not match template declaration isAssociativeArray(T)
/usr/include/dmd/phobos/std/traits.d(2586): Error: template instance std.traits.hasIndirections!(Payload).Impl!(__T23RepresentationTypeTupleTS3std9container54__T5ArrayTS4vibe4core7drivers9libevent212TimeoutEntryZ5Array7PayloadZ) error instantiating
/usr/include/dmd/phobos/std/traits.d(2590):        instantiated from here: Impl!(Payload, __T23RepresentationTypeTupleTS3std9container54__T5ArrayTS4vibe4core7drivers9libevent212TimeoutEntryZ5Array7PayloadZ)
/usr/include/dmd/phobos/std/typecons.d(3602):        instantiated from here: hasIndirections!(Payload)
/usr/include/dmd/phobos/std/container.d(2645):        instantiated from here: RefCounted!(Payload, cast(RefCountedAutoInitialize)0)
/home/oivind/.dub/packages/vibe-d-master/source/vibe/core/drivers/libevent2.d(75):        instantiated from here: Array!(TimeoutEntry)
/usr/include/dmd/phobos/std/traits.d(2590): Error: template instance std.traits.hasIndirections!(Payload).Impl!(Payload, __T23RepresentationTypeTupleTS3std9container54__T5ArrayTS4vibe4core7drivers9libevent212TimeoutEntryZ5Array7PayloadZ) error instantiating
/usr/include/dmd/phobos/std/typecons.d(3602):        instantiated from here: hasIndirections!(Payload)
/usr/include/dmd/phobos/std/container.d(2645):        instantiated from here: RefCounted!(Payload, cast(RefCountedAutoInitialize)0)
/home/oivind/.dub/packages/vibe-d-master/source/vibe/core/drivers/libevent2.d(75):        instantiated from here: Array!(TimeoutEntry)
/usr/include/dmd/phobos/std/typecons.d(3602): Error: template instance std.traits.hasIndirections!(Payload) error instantiating
/usr/include/dmd/phobos/std/container.d(2645):        instantiated from here: RefCounted!(Payload, cast(RefCountedAutoInitialize)0)
/home/oivind/.dub/packages/vibe-d-master/source/vibe/core/drivers/libevent2.d(75):        instantiated from here: Array!(TimeoutEntry)
/home/oivind/.dub/packages/vibe-d-master/source/vibe/core/drivers/libevent2.d(75): Error: template instance std.container.Array!(TimeoutEntry) error instantiating
/home/oivind/.dub/packages/vibe-d-master/source/vibe/core/drivers/libevent2.d(76): Error: BinaryHeap!(_error_, "a.timeout > b.timeout") had previous errors

I am running what is supposed to be DMD. 2.064.2 on Ubuntu 13.10. 'dmd -help' gives this:

DMD64 D Compiler v2.064-devel-a9eedd1

Re: HTTP server stopped working(?)

This appears to be an instance of #493. Building the latest git master of DUB from source should fix the errors by using a defined order for passing source files to the compiler. Otherwise, the latest DMD 2.065 beta also fixes the issue. Sorry for taking so long to answer, this post got buried under below a bunch of other messages.