我有一个由两部分组成的应用程序:一个使用graphql-subscriptions的React前端和一个带an MQTT broker的Node.js应用程序(及其Web套接字处理程序)和a subscription server。
As stated here,我没有使用默认的PubSub
实现(正在运行),而是尝试实现外部PubSub引擎,为此,我选择了graphql-redis-subscriptions。
每当邮件到达服务器时,我都会收到以下错误:
2018-03-27 14:52:03: assert.js:42
throw new errors.AssertionError({
^
AssertionError [ERR_ASSERTION]: undefined == true
at MQEmitterRedis.emit (node_modules/mqemitter/mqemitter.js:98:3)
at handler (node_modules/mqemitter-redis/mqemitter-redis.js:36:12)
at Redis.<anonymous> (node_modules/mqemitter-redis/mqemitter-redis.js:46:5)
at emitThree (events.js:136:13)
at Redis.emit (events.js:217:7)
at Redis.exports.returnReply ( node_modules/ioredis/lib/redis/parser.js:119:14)
at JavascriptRedisParser.returnReply ( node_modules/ioredis/lib/redis/parser.js:27:13)
at JavascriptRedisParser.execute ( node_modules/redis-parser/lib/parser.js:574:12)
at Socket.<anonymous> ( node_modules/ioredis/lib/redis/event_handler.js:107:22)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at TCP.onread (net.js:594:20)
我无法理解这里发生了什么。 By looking at the code, it seems that this assert is failing because the argument is undefined。
以下是PubSub.js
文件的配置,在发布内容时需要导入该文件:
import { RedisPubSub } from 'graphql-redis-subscriptions';
import config from '../config/getConfig';
const { port, host } = config.redisConf;
// Options listed here: https://github.com/luin/ioredis/blob/master/API.md#new_Redis_new
const pubsub = new RedisPubSub({
connection: {
host,
port,
retry_strategy: options => Math.max(options.attempt * 100, 3000),
},
});
export default pubsub;
然后,在另一个文件中,我只导入import pubSub from '../../helpers/PubSub';
并使用以下代码发布主题:
pubSub.publish(topic, { operation: { ... }});
你能否建议我做错了什么? 感谢