Repository: celery/celery

Issue:
TypeError in make_connection, unexpected keyword argument 'socket_keepalive'
# Checklist

- [ ] I have verified that the issue exists against the `master` branch of Celery.
- [ ] This has already been asked to the [discussion group](https://groups.google.com/forum/#!forum/celery-users) first.
- [x] I have read the relevant section in the
  [contribution guide](http://docs.celeryproject.org/en/latest/contributing.html#other-bugs)
  on reporting bugs.
- [x] I have checked the [issues list](https://github.com/celery/celery/issues?q=is%3Aissue+label%3A%22Issue+Type%3A+Bug+Report%22+-label%3A%22Category%3A+Documentation%22)
  for similar or identical bug reports.
- [x] I have checked the [pull requests list](https://github.com/celery/celery/pulls?q=is%3Apr+label%3A%22PR+Type%3A+Bugfix%22+-label%3A%22Category%3A+Documentation%22)
  for existing proposed fixes.
- [x] I have checked the [commit log](https://github.com/celery/celery/commits/master)
  to find out if the bug was already fixed in the master branch.
- [x] I have included all related issues and possible duplicate issues
  in this issue (If there are none, check this box anyway).

## Mandatory Debugging Information

- [ ] I have included the output of ``celery -A proj report`` in the issue.
    (if you are not able to do this, then at least specify the Celery
     version affected).
- [ ] I have verified that the issue exists against the `master` branch of Celery.
- [x] I have included the contents of ``pip freeze`` in the issue.
- [x] I have included all the versions of all the external dependencies required
  to reproduce this bug.

## Optional Debugging Information

- [ ] I have tried reproducing the issue on more than one Python version
  and/or implementation.
- [ ] I have tried reproducing the issue on more than one message broker and/or
  result backend.
- [ ] I have tried reproducing the issue on more than one version of the message
  broker and/or result backend.
- [ ] I have tried reproducing the issue on more than one operating system.
- [ ] I have tried reproducing the issue on more than one workers pool.
- [ ] I have tried reproducing the issue with autoscaling, retries,
  ETA/Countdown & rate limits disabled.
- [x] I have tried reproducing the issue after downgrading
  and/or upgrading Celery and its dependencies.

## Related Issues and Possible Duplicates

#### Related Issues

- #5952
- #2903

#### Possible Duplicates

- None

## Environment & Settings

**Celery version**: 4.4.1

# Steps to Reproduce

## Required Dependencies

### Python Packages

<details>
<summary><b><code>pip freeze</code> Output:</b></summary>
<p>
```
redis==3.4.1
billiard==3.6.3.0
celery==4.4.1
kombu==4.6.8
```
</p>
</details>

### Other Dependencies

<details>
<p>
N/A
</p>
</details>

## Minimally Reproducible Test Case

<details>
<p>

```python
```

</p>
</details>

# Expected Behavior

Celery just works

# Actual Behavior

After upgrading Celery from 4.4.0 to 4.4.1 I suddenly see `TypeError: __init__() got an unexpected keyword argument 'socket_keepalive'`.

This seems to be caused by PR #5952, which adds this kwarg for Redis connections. However, not all Redis connection constructors take the same arguments (e.g. `UnixDomainSocketConnection` doesn't take `socket_keepalive`). This seems to be happened before as noted in issue #2903.

Everything works fine if I downgrade to 4.4.0 again.


Discussion:
can you check the commit log after 4.4.1 release? this might have already resolved in master?
I did check the commit log (I also checked that option in the checklist). None of the (now) 4 commits since the release of 4.4.1 seem related to this issue.

I'm unable to test against master as the only place I can test this reliably is a production server. I was hoping Celery's tests would catch an issue like this, but it seems that the Travis pipeline is not running the integration tests.
ops sorry to know that! thanks for letting us know! will try to push another minor release ASAP

Resolving patch:
diff --git a/celery/backends/redis.py b/celery/backends/redis.py
--- a/celery/backends/redis.py
+++ b/celery/backends/redis.py
@@ -232,11 +232,14 @@ def __init__(self, host=None, port=None, db=None, password=None,
             'max_connections': self.max_connections,
             'socket_timeout': socket_timeout and float(socket_timeout),
             'retry_on_timeout': retry_on_timeout or False,
-            'socket_keepalive': socket_keepalive or False,
             'socket_connect_timeout':
                 socket_connect_timeout and float(socket_connect_timeout),
         }
 
+        # absent in redis.connection.UnixDomainSocketConnection
+        if socket_keepalive:
+            self.connparams['socket_keepalive'] = socket_keepalive
+
         # "redis_backend_use_ssl" must be a dict with the keys:
         # 'ssl_cert_reqs', 'ssl_ca_certs', 'ssl_certfile', 'ssl_keyfile'
         # (the same as "broker_use_ssl")


Test patch:
diff --git a/t/unit/backends/test_redis.py b/t/unit/backends/test_redis.py
--- a/t/unit/backends/test_redis.py
+++ b/t/unit/backends/test_redis.py
@@ -324,6 +324,7 @@ def test_socket_url(self):
         assert 'port' not in x.connparams
         assert x.connparams['socket_timeout'] == 30.0
         assert 'socket_connect_timeout' not in x.connparams
+        assert 'socket_keepalive' not in x.connparams
         assert x.connparams['db'] == 3
 
     @skip.unless_module('redis')