eidheim / Simple-Web-Server

A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio. Created to be an easy way to make REST resources available from C++ applications.
MIT License
2.61k stars 751 forks source link

Server 125 errors #204

Closed sharpie7 closed 6 years ago

sharpie7 commented 6 years ago

I am still trying to understand this and how to easily reproduce it, but I will post what I know and update as I learn.

A user of my library built on sws found that requests sent to the server weren't being processed. I was unable to reproduce on my machine for a long time, but by chance I now see what I think is the same error.

When the server receives what seems to be a valid request it reports two errors with code 125 and doesn't process the request. I created some debug output which shows the errors reported by the server and the line numbers on the stack when they occured (included below).

I am using the latest version of sws and ASIO stand-alone V1.10.6.

A wireshark trace for the flow that caused the error is here: https://www.dropbox.com/s/dey6wsfblluqk30/180124_1053_servererr.pcapng?dl=0 Note that the header and content of the HTTP request are split in to different TCP fragments. I guess this may be related to why the error occurs.

Debug trace: Server errror: generic:125 [bt] Execution path: [bt] d=1 ./osiotcmd() [0x464829] /home/iain/atis-os-iot/onem2m.cxx:852 [bt] d=2 ./osiotcmd() [0x46542e] /usr/include/c++/5/functional:1871 (discriminator 4) [bt] d=3 ./osiotcmd() [0x475afb] /usr/include/c++/5/functional:2268 [bt] d=4 ./osiotcmd() [0x47eb42] /home/iain/atis-os-iot/simplewebserver/server_http.hpp:678 (discriminator 2) [bt] d=5 ./osiotcmd() [0x4793b3] /home/iain/atis-os-iot/simplewebserver/server_http.hpp:632 [bt] d=6 ./osiotcmd() [0x475732] /home/iain/atis-os-iot/simplewebserver/server_http.hpp:494 [bt] d=7 ./osiotcmd() [0x47ee22] /home/iain/atis-os-iot/./asio-1.10.6/include/asio/impl/read.hpp:635 [bt] d=8 ./osiotcmd() [0x4a97a4] /home/iain/atis-os-iot/./asio-1.10.6/include/asio/detail/bind_handler.hpp:128 [bt] d=9 ./osiotcmd() [0x4a5536] /home/iain/atis-os-iot/./asio-1.10.6/include/asio/handler_invoke_hook.hpp:69 [bt] d=10 ./osiotcmd() [0x4a0eb3] /home/iain/atis-os-iot/./asio-1.10.6/include/asio/detail/handler_invoke_helpers.hpp:39 [bt] d=11 ./osiotcmd() [0x49db06] /home/iain/atis-os-iot/./asio-1.10.6/include/asio/impl/read.hpp:684 [bt] d=12 ./osiotcmd() [0x4995e4] /home/iain/atis-os-iot/./asio-1.10.6/include/asio/detail/handler_invoke_helpers.hpp:39 [bt] d=13 ./osiotcmd() [0x494707] /home/iain/atis-os-iot/./asio-1.10.6/include/asio/detail/reactive_socket_recv_op.hpp:107 [bt] d=14 ./osiotcmd() [0x467d1c] /home/iain/atis-os-iot/./asio-1.10.6/include/asio/detail/task_io_service_operation.hpp:38 [bt] d=15 ./osiotcmd() [0x469d43] /home/iain/atis-os-iot/./asio-1.10.6/include/asio/detail/impl/epoll_reactor.ipp:653 Server errror: asio.system:125 [bt] Execution path: [bt] d=1 ./osiotcmd() [0x464829] /home/iain/atis-os-iot/onem2m.cxx:852 [bt] d=2 ./osiotcmd() [0x46542e] /usr/include/c++/5/functional:1871 (discriminator 4) [bt] d=3 ./osiotcmd() [0x475afb] /usr/include/c++/5/functional:2268 [bt] d=4 ./osiotcmd() [0x475132] /home/iain/atis-os-iot/simplewebserver/server_http.hpp:511 (discriminator 2) [bt] d=5 ./osiotcmd() [0x47fbc2] /home/iain/atis-os-iot/./asio-1.10.6/include/asio/impl/read_until.hpp:637 [bt] d=6 ./osiotcmd() [0x4a98ae] /home/iain/atis-os-iot/./asio-1.10.6/include/asio/detail/bind_handler.hpp:128 [bt] d=7 ./osiotcmd() [0x4a56a5] /home/iain/atis-os-iot/./asio-1.10.6/include/asio/handler_invoke_hook.hpp:69 [bt] d=8 ./osiotcmd() [0x4a1021] /home/iain/atis-os-iot/./asio-1.10.6/include/asio/detail/handler_invoke_helpers.hpp:39 [bt] d=9 ./osiotcmd() [0x49de7e] /home/iain/atis-os-iot/./asio-1.10.6/include/asio/impl/read_until.hpp:684 [bt] d=10 ./osiotcmd() [0x499eb4] /home/iain/atis-os-iot/./asio-1.10.6/include/asio/detail/handler_invoke_helpers.hpp:39 [bt] d=11 ./osiotcmd() [0x494e7a] /home/iain/atis-os-iot/./asio-1.10.6/include/asio/detail/reactive_socket_recv_op.hpp:107 [bt] d=12 ./osiotcmd() [0x467d1c] /home/iain/atis-os-iot/./asio-1.10.6/include/asio/detail/task_io_service_operation.hpp:38 [bt] d=13 ./osiotcmd() [0x46a9c9] /home/iain/atis-os-iot/./asio-1.10.6/include/asio/detail/impl/task_io_service.ipp:373 [bt] d=14 ./osiotcmd() [0x46a385] /home/iain/atis-os-iot/./asio-1.10.6/include/asio/detail/impl/task_io_service.ipp:148 (discriminator 2) [bt] d=15 ./osiotcmd() [0x46ac88] /home/iain/atis-os-iot/./asio-1.10.6/include/asio/impl/io_service.ipp:58

sharpie7 commented 6 years ago

This seems to be related to some of my processing - if I remove part of my request handler routine the error goes away. I will investigate this more closely.

In the meantime, if the logs suggest what the cause of the error is then I would like to hear that!

sharpie7 commented 6 years ago

OK - problem is my code throwing an exception during the handling of the request. red face

At least I learnt something.

eidheim commented 6 years ago

Glad you figured it out:)