Skip to content

fix framer close #45

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

Closed
wants to merge 1 commit into from
Closed

fix framer close #45

wants to merge 1 commit into from

Conversation

PeterRunich
Copy link
Contributor

Types of Changes

  • Bug fix.

@ioquatix
Copy link
Member

ioquatix commented Feb 3, 2023

The problem with this is that it will potentially close every other connection in the pool when one client connection is closed, which doesn't really make sense.

@ioquatix
Copy link
Member

ioquatix commented Feb 3, 2023

I've fixed this differently:

class ClientCloseDecorator < SimpleDelegator
def initialize(client, connection)
@client = client
super(connection)
end
def close
super
if @client
@client.close
@client = nil
end
end
end
# @return [Connection] an open websocket connection to the given endpoint.
def self.connect(endpoint, *arguments, **options, &block)
client = self.open(endpoint, *arguments)
connection = client.connect(endpoint.authority, endpoint.path, **options)
return ClientCloseDecorator.new(client, connection) unless block_given?
begin
yield connection
ensure
connection.close
client.close
end
end

@ioquatix ioquatix closed this Feb 3, 2023
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

Successfully merging this pull request may close these issues.

2 participants