Я пытаюсь настроить синтаксический анализ LiveQuery, но застреваю.На клиенте я могу открыть соединение, но LiveQuery не обновит клиента, когда я внесу изменения на сервере.Что я делаю неправильно?Есть ли лучший способ настроить?
Вот что у меня происходит в клиенте:
Parse.liveQueryServerURL = 'ws://myawsEB-LiveQuery.com'
var Message = Parse.Object.extend('Room');
var query = new Parse.Query(Message);
query.include("messages");
// Subscribes to incoming messages
query.subscribe().then(subscription =>{
subscription.on('open', () => {
console.log('subscription opened'); // THIS WORKS!
});
subscription.on('create', function (message) {
console.log("create: ", message); //THIS DOES NOT WORK
});
subscription.on('update', function (message) {
console.log("update: ", message); //THIS DOES NOT WORK
});
})
.catch(error => {
console.log(error)
});
Моя настройка AWS:
AWS EB - Main App
AWS EB - Parse LiveQuery
AWS ElastiCache - Redis
Вот моя конфигурация сервера:
//Main APP
var api = new ParseServer({
appName: "app-name",
databaseURI: databaseUri,
cloud: process.env.CLOUD_CODE_MAIN,
appId: process.env.APP_ID,
masterKey: process.env.MASTER_KEY
fileKey: process.env.FILE_KEY,
serverURL: process.env.SERVER_URL,
publicServerURL: process.env.SERVER_URL,
clientKey: process.env.CLIENT_KEY,
javascriptKey: process.env.JAVASCRIPT_KEY,
liveQuery: {
classNames: ["Room", "Messages"], // List of classes to support for query subscriptions
redisURL: process.env.redisURL
},
databaseOptions: { poolSize: 500 },
maxUploadSize: "5mb",
verbose: true
});
var port = process.env.PORT || 1337;
var httpServer = require('http').createServer(app);
httpServer.listen(port, function() {
console.log('parse-server-example running on port ' + port + '.');
});
Вот мои настройки сервера LiveQuery:
//Live Query Server
var express = require('express');
var cors = require('cors')
var ParseServer = require('parse-server').ParseServer;
var app = express();
app.use(cors());
// We include the lines below so that we can hit `/` and it passes the Elastic Beanstalk Health Check
app.get('/', function(req, res) {
res.status(200).send('Make sure to star the parse-server repo on GitHub!');
});
var port = process.env.PORT || 1338;
var httpServer = require('http').createServer(app);
httpServer.listen(port, function() {
console.log('parse-server-example running on port ' + port + '.');
});
ParseServer.createLiveQueryServer(httpServer, {
appId: process.env.APP_ID, // same as main-index.js file below
masterKey: process.env.MASTER_KEY, // same as main-index.js
serverURL: process.env.SERVER_URL, // socket.myApp.com
javascriptKey: process.env.JAVASCRIPT_KEY,
redisURL: process.env.redisURL,
websocketTimeout: 10 * 1000,
cacheTimeout: 60 * 600 * 1000,
verbose: true
});