# socket.io-ioredis

> ## How to use

Latest version **1.4.1** (published 2016-06-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install socket.io-ioredis
pnpm add socket.io-ioredis
yarn add socket.io-ioredis
bun add socket.io-ioredis
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.1 |
| Published | 2016-06-10 |
| First published | 2015-08-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 11 |
| Maintainers | fracmak |

## Links

- npm: https://www.npmjs.com/package/socket.io-ioredis
- Repository: https://github.com/GannettDigital/socket.io-ioredis
- Homepage: https://github.com/GannettDigital/socket.io-ioredis#readme
- Issues: https://github.com/GannettDigital/socket.io-ioredis/issues
- npm.io page: https://npm.io/package/socket.io-ioredis

## Dependencies (5)

- [uid2](https://npm.io/package/uid2.md) 0.0.3
- [debug](https://npm.io/package/debug.md) 2.2.0
- [ioredis](https://npm.io/package/ioredis.md) ^1.7.3
- [msgpack-js](https://npm.io/package/msgpack-js.md) 0.3.0
- [socket.io-adapter](https://npm.io/package/socket.io-adapter.md) ^0.4.0

## Recent versions

- 1.4.1 (latest) — 2016-06-10
- 1.4.0 — 2016-03-08
- 1.3.0 — 2016-03-08
- 1.2.0 — 2016-03-08
- 1.1.0 — 2016-03-07
- 1.0.1 — 2015-08-11
- 1.0.0 — 2015-08-11

## README

# socket.io-ioredis

## How to use

```js
var io = require('socket.io')(3000);
var redis = require('socket.io-ioredis');
io.adapter(redis({ host: 'localhost', port: 6379 }));
```

By running socket.io with the `socket.io-ioredis` adapter you can run
multiple socket.io instances in different processes or servers that can
all broadcast and emit events to and from each other.

If you need to emit events to socket.io instances from a non-socket.io
process, you should use [socket.io-emitter](https:///github.com/Automattic/socket.io-emitter).

## API

### adapter(uri[, opts])

`uri` is a string like `localhost:6379` where your redis server
is located. For a list of options see below.

### adapter(opts)

The following options are allowed:

- `key`: the name of the key to pub/sub events on as prefix (`socket.io`)
- `host`: host to connect to redis on (`localhost`)
- `port`: port to connect to redis on (`6379`)
- `pubClient`: optional, the redis client to publish events on
- `subClient`: optional, the redis client to subscribe to events on

If you decide to supply `pubClient` and `subClient`, make sure you use
[ioredis](https://github.com/luin/ioredis) as a client.

### RedisAdapter

The redis adapter instances expose the following properties
that a regular `Adapter` does not

- `uid`
- `prefix`
- `pubClient`
- `subClient`

## Client error handling

Access the `pubClient` and `subClient` properties of the
Redis Adapter instance to subscribe to its `error` event:

```js
var redis = require('socket.io-redis');
var adapter = adapter('localhost:6379');
adapter.pubClient.on('error', function(){});
adapter.subClient.on('error', function(){});
```

## License

MIT

---
_Source: https://npm.io/package/socket.io-ioredis · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
