Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTPS server timeout is inaccurate #72

Open
triska opened this issue Dec 17, 2016 · 2 comments
Open

HTTPS server timeout is inaccurate #72

triska opened this issue Dec 17, 2016 · 2 comments

Comments

@triska
Copy link
Member

triska commented Dec 17, 2016

When I set timeout/1 in an HTTPS server, I get about twice the timeout that I actually set.

As a test case, place https_server.pl in packages-ssl, consisting of:

:- use_module(library(http/thread_httpd)).
:- use_module(library(http/http_ssl_plugin)).

https_server(Port, Options) :-
        http_server(reply,
                    [ port(Port),
                      ssl([ certificate_file('etc/server/server-cert.pem'),
                            key_file('etc/server/server-key.pem'),
                            password(apenoot1)
                          ])
                    | Options
                    ]).
reply(_) :-
        format("Content-type: text/plain~n~n"),
        format("Hello!").

Start the server with:

$ swipl https_server.pl 
...

?- https_server(1125, [timeout(5)]).
% Started server at https://localhost:1125/
true.

Then, connect to the server via:

$ time openssl s_client -connect localhost:1125

After about 10 seconds, I get:

...
read:errno=0

real	0m10.019s
user	0m0.000s
sys	0m0.004s
@triska
Copy link
Member Author

triska commented Dec 19, 2016

As another test case, the default timeout of 60 seconds becomes 2 minutes, likely due to the same issue.

I think this issue is a good candidate to look into before the stable release, since reliable timeouts help to increase robustness.

@JanWielemaker
Copy link
Member

My suspicion is that somehow the low-level stuff needs to timeout twice before it gets through the SSL layer. Just a factor 2 off isn't that vital. Typically timeout values are nearly random educated guesses anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants