Faye Ruby Server Side Publish on Heroku - EventMachine buffer overflow detected

198 views Asked by At

I have a faye ruby client on a heroku worker (using sidekiq - 5 threads) that publishes to the faye server running on linode.

The worker crashes after a few minutes with a buffer overflow detected message.

*Code

  EM.epoll

  EM.run {
    publication = @client.publish('/glive-bullion','body'=>body)

    publication.callback do
      EM.stop_event_loop
    end

    publication.errback do |error|
      puts 'There was a problem: ' + error.message
      EM.stop_event_loop
    end

  }

I have tried the following: 1) EM.epoll before EM.run 2) EM.stop_event_loop in the respective callbacks.

I understand that the file descriptor restriction is causing this issue.

Question: How do i release the client and stop the EM event loop to release the open file completely?

Is it because of sidekiq running in threaded mode?

1

There are 1 answers

0
dhakadamit On BEST ANSWER

Ok, I realised the mistake.

I was creating the client outside the EM.run block. Once i moved the initialization inside the EM.run block, everything was working fine.