Skip to content

Zombies HTTP connections raise TCP exception #25

@kremio

Description

@kremio

Hello,
I've noticed that after a certain number of queries, the following exception occurs:
Failed to open TCP connection to api.figo.me:443 (getaddrinfo: Temporary failure in name resolution)

I've wrote and ran a test to get more insight in the problem. Here is the pseudo code for the test:

loop do
connection = Figo::Connection.new(...)
connection.credential_login(...) #Doesn't matter if the credentials are valid, this is just to send a query
end

On my machine, the loop breaks because of the TCP connection error after exactly 241 iterations.

After looking a the source code for Figo::Connection, I noticed that the HTTP connection was never shutdown. So I extended Figo::Connection like so:

class FigoConnection < Figo::Connection
  def done
    @https.shutdown
  end
end

and modified the test to call done after each query:

loop do
connection = FigoConnection.new(...)
connection.credential_login(...) 
connection.done
end

and now the loop keeps on going after 241 iterations.
The same issue exists in Figo::Session (I haven't tested it but the HTTP connection is managed the same way)

For now, I'm going to extend Figo::Connection and Figo::Session to handle the termination of HTTP connections in my application code.

It would be extremely nice if the ruby-figo gem would manage the connection itself, so this would be transparent to the application code.

Best regards.

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