swift - Parse Server LiveQuery 没有响应 AWS

标签 swift amazon-web-services parse-platform redis

我使用两台 Parse 服务器,一台用于主数据库,一台用于 liveQuery。我还通过 AWS ElastiCache 设置了一个 redis。问题是当我在客户端 (iOS) 中使用实时查询时,没有显示任何事件。代码对任何更改都没有响应。这里可能是什么问题?

一个问题:来自 AWS Elasticache 的 redisURL 是这样的:(这会在服务器启动时出错) appname.jajj2i.0001.use1.cache.amazonaws.com:6379

我应该像这样将 redis://添加到开头吗:(我已经这样做了) redis://appname.jajj2i.0001.use1.cache.amazonaws.com:6379


我的主要解析服务器代码如下:

var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var app = express();
// Specify the connection string for your mongodb database
// and the location to your Parse cloud code
var S3Adapter = require('parse-server').S3Adapter
var api = new ParseServer({
    databaseURI: "main_database_uri",
    appId: "main_app_id",
    masterKey: "main_master_key",
    fileKey: "main_file_key",
    serverURL: "main_server_rul",

liveQuery: {
    classNames: ['Chats', 'Messages'],
    redisURL: 'redis_url'
  },

filesAdapter: new S3Adapter(
    "S3_Key",
    "S3_key",
    "S3_bucket_name",
    {directAccess: true}
  ),

});
// Serve the Parse API on the /parse URL prefix
app.use('/parse', api);

var port = 1337;
app.listen(port, function() {
    console.log('parse-server running on port ' + port);
});

//Parse Dashboard
var ParseDashboard = require('parse-dashboard');
var dashboard = new ParseDashboard({
    apps: [
        {
            appName: "My Bitnami Parse API",
            appId: "appId",
            masterKey: "masterKey",
            fileKey: "fileKey",
            production: true,
            serverURL: "serverUrl"
        }
    ],
    users: [
        {
            user: "username",
            pass: "password"
        }
    ], useEncryptedPasswords: true
});

var allowInsecureHTTP = true;

// Serve the Parse Dashboard on the /parsedashboard URL prefix
app.use('/', dashboard);

var portdash = 4040;
app.listen(portdash, function() {
    console.log('parse-dashboard running on port ' + portdash);
});

我的liveQuery服务器代码如下:

var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var app = express();
// Specify the connection string for your mongodb database
// and the location to your Parse cloud code
var api = new ParseServer({
    databaseURI: "main_database_uri",
    appId: "live_appId",
    masterKey: "live_master_key",
    fileKey: "live_file_key",
    serverURL: "live_server_url"
});
// Serve the Parse API on the /parse URL prefix
app.use('/parse', api);

var port = 1337;
app.listen(port, function() {
    console.log('parse-server running on port ' + port);
});

//Parse Dashboard
var ParseDashboard = require('parse-dashboard');
var dashboard = new ParseDashboard({
    apps: [
        {
            appName: "My Bitnami Parse API",
            appId: "appid",
            masterKey: "masterkey",
            fileKey: "filekey",
            production: true,
            serverURL: "serverUrl"
        }
    ],
    users: [
        {
            user: "username",
            pass: "password"
        }
    ], useEncryptedPasswords: true
});

var allowInsecureHTTP = true;
// Serve the Parse Dashboard on the /parsedashboard URL prefix
app.use('/', dashboard);

var portdash = 4040;
app.listen(portdash, function() {
    console.log('parse-dashboard running on port ' + portdash);
});


var porthttp = 8030;
var httpServer = require('http').createServer(app);
httpServer.listen(porthttp, function() {
  /* Create HTTP server successfully */
});

ParseServer.createLiveQueryServer(httpServer, {
  redisURL: 'RedisUrl' // Redis URL from Main app
});

我的客户代码:

override func viewDidLoad() {
    super.viewDidLoad()

    let client = Client(server: "liveQuery_server", applicationId: "liveQuery_appId", clientKey: nil)

    Chats.registerSubclass()

    let query = PFQuery(className: "Chats").whereKey("chats", equalTo: "zaa")

    subscription = client.subscribe(query)

    subscription?.handle(Event.created) { (query, object) in

        print(object)

    }

}

最佳答案

import ParseLiveQuery
import BoltsSwift

let liveQueryClient: Client = ParseLiveQuery.Client(server: "wss://server.io")



 private var subscription: Subscription<PFObject>!
    var messagesArray : [PFObject] = [PFObject]()
    var msgQuery = PFQuery(className: "Inbox").whereKeyExists("message")

关于swift - Parse Server LiveQuery 没有响应 AWS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48251927/

相关文章:

java - 如何将 EditText 的内容放到 Parse.com 上?

javascript - AngularJS 在页面加载时运行一系列函数

ios - ViewControl 之外的 Swift 选择器

ios - 绘制 UITableView 的单元格会出现视觉错误

ios - 如何在不在 ViewController 类中时以编程方式更改 View Controller

ios - 使用 accesskey 和 secretkey 从 S3 服务器下载安全文件

amazon-web-services - AWS Cloudwatch Logs Lambda 订阅被多次触发

ios - 警告 : Attempt to present UINavigationController on UIViewController which is already presenting

amazon-web-services - 嵌套 AWS Cloudformation 堆栈与使用 SSM 参数存储

objective-c - libz.dylib libsqlite3.dylib 不在 Xcode 7 中,解析不保存数据