Closed vidcentum closed 4 years ago
I don't see any criminal here.
By the default RESTinio works that way: reads an incoming HTTP request, passes it to a request-handler and doesn't read anything from the client until request-handler completes the handling of the request. After sending the reply RESTinio starts reading the connection of the client to get a new HTTP request from this connection. This is what you see in the log:
This is the completion of the processing of the current request:
[2020-04-21 15:14:36.244] TRACE: [connection:2] append response (#0), flags: { final_parts, connection_keepalive }, write group size: 2
[2020-04-21 15:14:36.244] TRACE: [connection:2] start next write group for response (#0), size: 2
[2020-04-21 15:14:36.244] TRACE: [connection:2] start response (#0): HTTP/1.1 200 OK
[2020-04-21 15:14:36.244] TRACE: [connection:2] sending resp data, buf count: 2, total size: 101
[2020-04-21 15:14:36.244] TRACE: [connection:2] outgoing data was sent: 101 bytes
[2020-04-21 15:14:36.244] TRACE: [connection:2] finishing current write group
[2020-04-21 15:14:36.244] TRACE: [connection:2] should keep alive
Note also should keep alive
. It tells that RESTinio won't close the current connection after sending the reply.
This the start of reading a new request from the client:
[2020-04-21 15:14:36.245] TRACE: [connection:2] start waiting for request
[2020-04-21 15:14:36.245] TRACE: [connection:2] continue reading request
This behavior can be changed by turning HTTP pipelining on (see here some explanation).
I wanted to test the API using Advanced Rest Client application. I issued GET API http://localhost:5000/logout Now, I receive response very late
Sometimes I get similar behavior with curl
command if a response is too short. curl
simple doesn't show short responses until the connection is closed or another bunch of data arrived from the server.
Hi, Thank you for your quick response. I got the point. I tested again with simple Python client programs and it works. Thank you. I am closing the issue. Best Regards Maruthi
Hi,
I am developing APIs using Restinio. I developed a simple application with the help of sample/async_handling_with_sobjectizer/main.cpp and express router.
Example route: /logout HTTP Method: GET
When I call http://localhost:5000/logout from the browser, I get the response immediately. I think it works well.
I wanted to test the API using Advanced Rest Client application. I issued GET API http://localhost:5000/logout
Now, I receive response very late and please find the console log herewith.
Could you please help where I am making a mistake?
Not sure the server is reading req after start response (#0): HTTP/1.1 200 OK
####################
[2020-04-21 15:14:35.948] TRACE: accept connection from 127.0.0.1:35476 on socket #0 [2020-04-21 15:14:35.948] TRACE: [connection:2] start connection with 127.0.0.1:35476 [2020-04-21 15:14:35.948] TRACE: [connection:2] start waiting for request [2020-04-21 15:14:35.948] TRACE: [connection:2] continue reading request [2020-04-21 15:14:35.948] TRACE: [connection:2] received 46 bytes [2020-04-21 15:14:35.951] TRACE: [connection:2] request received (#0): GET /logout [2020-04-21 15:14:36.244] TRACE: [connection:2] append response (#0), flags: { final_parts, connection_keepalive }, write group size: 2 [2020-04-21 15:14:36.244] TRACE: [connection:2] start next write group for response (#0), size: 2 [2020-04-21 15:14:36.244] TRACE: [connection:2] start response (#0): HTTP/1.1 200 OK [2020-04-21 15:14:36.244] TRACE: [connection:2] sending resp data, buf count: 2, total size: 101 [2020-04-21 15:14:36.244] TRACE: [connection:2] outgoing data was sent: 101 bytes [2020-04-21 15:14:36.244] TRACE: [connection:2] finishing current write group [2020-04-21 15:14:36.244] TRACE: [connection:2] should keep alive [2020-04-21 15:14:36.245] TRACE: [connection:2] start waiting for request [2020-04-21 15:14:36.245] TRACE: [connection:2] continue reading request
[2020-04-21 15:15:01.669] TRACE: [connection:2] EOF and no request, close connection [2020-04-21 15:15:01.669] TRACE: [connection:2] close [2020-04-21 15:15:01.669] TRACE: [connection:2] close: close socket [2020-04-21 15:15:01.669] TRACE: [connection:2] close: timer canceled [2020-04-21 15:15:01.669] TRACE: [connection:2] close: reset responses data [2020-04-21 15:15:01.669] TRACE: [connection:2] destructor called
###########