Issue 1:
Checklist

software -> celery:4.2.0rc4 (windowlicker) kombu:4.2.0 py:2.7.12
billiard:3.5.0.3 py-amqp:2.3.1
platform -> system:Linux arch:64bit, ELF imp:CPython
loader -> celery.loaders.default.Loader
settings -> transport:amqp results:disabled

I have verified that the issue exists against the master branch of Celery.

Celery versions affected: 4.2.0rc4, 4.2.0rc2

Last working version: 4.1.1

Steps to reproduce

Start up a worker with gevent pool

send celery control cancel_consumer remote comand

Send celery control add_consumer remote command

Expected behavior

Cancel consumer should remove all the workers consuming from the given queue

Add consumer should add a specified consumer to the given queue

Actual behavior

Cancel consumer removes the workers from the queue as expected

Add consumer throws the following exception and the worker dies

Traceback (most recent call last):
worker_1 | File "/usr/local/lib/python2.7/site-packages/gevent/hub.py", line 866, in switch
worker_1 | switch(value)
worker_1 | File "/usr/local/lib/python2.7/site-packages/celery/worker/pidbox.py", line 120, in loop
worker_1 | connection.drain_events(timeout=1.0)
worker_1 | File "/usr/local/lib/python2.7/site-packages/kombu/connection.py", line 301, in drain_events
worker_1 | return self.transport.drain_events(self.connection, **kwargs)
worker_1 | File "/usr/local/lib/python2.7/site-packages/kombu/transport/pyamqp.py", line 103, in drain_events
worker_1 | return connection.drain_events(**kwargs)
worker_1 | File "/usr/local/lib/python2.7/site-packages/amqp/connection.py", line 491, in drain_events
worker_1 | while not self.blocking_read(timeout):
worker_1 | File "/usr/local/lib/python2.7/site-packages/amqp/connection.py", line 496, in blocking_read
worker_1 | frame = self.transport.read_frame()
worker_1 | File "/usr/local/lib/python2.7/site-packages/amqp/transport.py", line 243, in read_frame
worker_1 | frame_header = read(7, True)
worker_1 | File "/usr/local/lib/python2.7/site-packages/amqp/transport.py", line 418, in _read
worker_1 | s = recv(n - len(rbuf))
worker_1 | File "/usr/local/lib/python2.7/site-packages/gevent/_socket2.py", line 277, in recv
worker_1 | return sock.recv(*args)
worker_1 | error: [Errno 104] Connection reset by peer
worker_1 | Mon May 28 19:40:01 2018 <built-in method switch of greenlet.greenlet object at 0x7f5b24653c30> failed with error

Issue 2:
Celery version: 4.2.0

Steps to reproduce

docker-compose.yml

version: '2'

services:
worker:
build: .
depends_on:
- rabbitmq

rabbitmq:
image: rabbitmq:alpine

Dockerfile

FROM alpine

RUN apk add --no-cache build-base python3 python3-dev
RUN pip3 install celery eventlet

CMD celery -b amqp://rabbitmq worker -P eventlet --loglevel=DEBUG

$ docker-compose up --build

Expected behavior

Worker stays connected without errors

Actual behavior

3 minutes after startup, the worker reports several errors with a Traceback, similar to the following:

[2018-06-14 20:11:44,213: WARNING/MainProcess] Traceback (most recent call last):
[2018-06-14 20:11:44,213: WARNING/MainProcess] File "/usr/lib/python3.6/site-packages/eventlet/hubs/poll.py", line 114, in wait
listener.cb(fileno)
[2018-06-14 20:11:44,214: WARNING/MainProcess] File "/usr/lib/python3.6/site-packages/celery/worker/pidbox.py", line 120, in loop
connection.drain_events(timeout=1.0)
[2018-06-14 20:11:44,214: WARNING/MainProcess] File "/usr/lib/python3.6/site-packages/kombu/connection.py", line 301, in drain_events
return self.transport.drain_events(self.connection, **kwargs)
[2018-06-14 20:11:44,215: WARNING/MainProcess] File "/usr/lib/python3.6/site-packages/kombu/transport/pyamqp.py", line 103, in drain_events
return connection.drain_events(**kwargs)
[2018-06-14 20:11:44,216: WARNING/MainProcess] File "/usr/lib/python3.6/site-packages/amqp/connection.py", line 491, in drain_events
while not self.blocking_read(timeout):
[2018-06-14 20:11:44,217: WARNING/MainProcess] File "/usr/lib/python3.6/site-packages/amqp/connection.py", line 496, in blocking_read
frame = self.transport.read_frame()
[2018-06-14 20:11:44,217: WARNING/MainProcess] File "/usr/lib/python3.6/site-packages/amqp/transport.py", line 243, in read_frame
frame_header = read(7, True)
[2018-06-14 20:11:44,218: WARNING/MainProcess] File "/usr/lib/python3.6/site-packages/amqp/transport.py", line 426, in _read
raise IOError('Socket closed')
[2018-06-14 20:11:44,218: WARNING/MainProcess] OSError: Socket closed
[2018-06-14 20:11:44,219: WARNING/MainProcess] Removing descriptor: 7

In addition, the rabbitmq server reports warnings similar to the following (repeated twice):

2018-06-14 20:11:44.209 [warning] <0.586.0> closing AMQP connection <0.586.0> (172.19.0.3:42678 -> 172.19.0.2:5672):
missed heartbeats from client, timeout: 60s