JuliaWeb / GnuTLS.jl

Transport Level Security for Julia Streams provided by GnuTLS
Other
8 stars 13 forks source link

readtobuf appears to be hitting timeout #34

Closed sbromberger closed 9 years ago

sbromberger commented 9 years ago

This is a running issue to document debugging notes on GnuTLS.jl.

Right now I'm seeing ~45second timeouts between a call to record_recv and the return of "0" bytes - this happens as the remote connection runs out of things to send. The time between the entry into

    ret = ccall((:gnutls_record_recv,gnutls), Int, (Ptr{Void},Ptr{Uint8},Csize_t), io.handle, pointer(buf.data,buf.size+1), nb)

and its exit is pretty consistent. I don't know whether there's a way to prevent blocking when there are no more bytes - the GnuTLS documentation is vague on this point and says that configuration of blocking is done at the socket level, which doesn't appear to be implemented in Julia's connect().

sbromberger commented 9 years ago

I've tracked down a possible problem: nb_available(Session) isn't reliable, but nb_available(Session.read) is. Therefore, when checking to see whether additional data to be read exists, we need to check the sum of those two. I've set up https://github.com/JuliaWeb/GnuTLS.jl/commit/3f3ea44055ba35e4a0ade927b35faa149476e3c5 and this seems to work pretty well but needs more testing.

sbromberger commented 9 years ago

readall() now seems to be appending "\r\n0\r\n\r\n" to the end of every get. I'm not sure why this is.

Edit: I've confirmed this is in readtobuf(). This is problematic. Need to find out whether it's an issue with the underlying libgnutls.

Edit2: related? http://www.experts-exchange.com/Networking/Protocols/SSL/Q_26635489.html#a34235148

Edit3: related to chunked encoding. Safe to disregard.

sbromberger commented 9 years ago

Closing out since we've merged #36.