Skip to content
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

Closing the client connection immediately after servers connection are closed #11

Closed
martinpoljak opened this issue Mar 26, 2011 · 1 comment

Comments

@martinpoljak
Copy link

If servers close all their connections to proxy, em-proxy immediately close (after writing currently written data) the connection to client too:

  def unbind_backend(name)
    debug [:unbind_backend, name]
    @servers[name] = nil

    # if all connections are terminated downstream, then notify client
    close_connection_after_writing if @servers.values.compact.size.zero?

    if @on_finish
      @on_finish.call(name)

      # not sure if this is required
      # @on_finish.call(:done) if @servers.values.compact.size.zero?
    end
  end

Problem occurs in cases, when we have some data from downstream in processing and server close the connection before our data for client is prepared for send. At these cases we need to say, we don't want to close connection to client just now, but manually later.

Some appropriate solution can be for example something similar to:

  def unbind_backend(name)
   debug [:unbind_backend, name]
    @servers[name] = nil
    close = :close

    if @on_finish
      close = @on_finish.call(name)
    end

    # if all connections are terminated downstream, then notify client
    if @servers.values.compact.size.zero? and close != :keep
      close_connection_after_writing
    end

  end
@igrigorik
Copy link
Owner

Hmm, that seems to make sense.. Do you have an example of how you would manually close the connection later?

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

No branches or pull requests

2 participants