Skip to content

HTTP2 Stream closed with "large" payloads #24

@manuelbb-upb

Description

@manuelbb-upb

I encountered a strange error whenever my payloads grew too large (150kb or more).
Whenever I would make request against our Python server, it would error with
ERROR: LoadError: gRPCServiceCallException: 12
but only on the very first run of the skript. In a REPL, the second request would usually work as expected.

I guess it is due to some timeout and I could overcome it by changing the send_data method in "curl.jl"
What I have finally come up with in my fork is this

function send_data(easy::Curl.Easy, input::Channel{T}, max_send_message_length::Int) where T <: ProtoType
    for input_obj in input
        input_buf = to_delimited_message_buffer( input_obj, max_send_message_length )
	Downloads.upload_data( easy, input_buf ) 
	# `upload_data` is missing the `yield()` statement
	# but if I put it there, something errors
    end
    return nothing
end

function to_delimited_message_buffer(msg, max_message_length::Int)
    iob = IOBuffer()
    limitiob = LimitIO(iob, max_message_length)
    write(limitiob, UInt8(0))                   # compression
    write(limitiob, hton(UInt32(0)))            # message length (placeholder)
    data_len = writeproto(limitiob, msg)        # message bytes

    seek(iob, 1)                                # seek out the message length placeholder
    write(iob, hton(UInt32(data_len)))          # fill the message length
    seek(iob, 0)
    return iob
end

I don't really know if this rewritten version of send_data suits all possible use-cases. I only use a blocking client and there it seems to do well enough.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions