Skip to content

Event source returned unexpected content type '' #210

@matt-dutchie

Description

@matt-dutchie

Describe the bug

Hello.

I'm attempting to update our code to use v7.0.2 of the ruby SDK. I'm receiving the following error when I try to boot up a client:

[2023-02-22T18:08:50] INFO  | [LDClient] Initializing stream connection
[2023-02-22T18:08:50] INFO  | Connecting to event stream at https://stream.launchdarkly.com/all
[2023-02-22T18:08:50] WARN  | Event source returned unexpected content type ''
...
# Times out, then retries ad nauseum

Tracing this bug backwards, I was able to reproduce starting in v6.0.0.

After doing a little code spelunking in the ld-eventsource plugin, I ran the following code to see if something weird is going on with the http request:

client = HTTP::Client.new()

sdk_key = # using our sdk key
headers = {
  "Accept"=>"text/event-stream",
  "Cache-Control"=>"no-cache",
  "User-Agent"=>"ruby-eventsource",
  "Authorization" => sdk_key
}

client.request("GET", "https://stream.launchdarkly.com/all", { headers: headers })

# => #<HTTP::Response/1.1 200 OK {"Date"=>"Thu, 23 Feb 2023 00:27:40 GMT", "Content-Type"=>"text/event-stream; charset=utf-8", "Transfer-Encoding"=>"chunked", "Connection"=>"close", "Accept-Ranges"=>"bytes", "Cache-Control"=>"no-cache, no-store, must-revalidate", "Etag"=>"\"9347c\"", "Ld-Region"=>"us-east-1", "Strict-Transport-Security"=>["max-age=31536000", "max-age=31536000"]}>

While not exactly analogous to your HTTP::Client usage within the ruby-eventsource plugin powering the connection, this seems to be at odds with the error case here: https://github.com/launchdarkly/ruby-eventsource/blob/68a3a91b70d13919a7b0fdcc5863483b3d52f802/lib/ld-eventsource/client.rb#L272

I'll keep digging but any help would be useful.

We are pegged to Faraday v1.10.0 and http v4.4.1 for dependency reasons.

Thank you.

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