I have a parse server running in clustering, everything works perfectly but in the last days I have had to add live queries, just activate it in the configuration doesn't work very well, because the event "create" is triggered only few times (while not in clustering it doesn't miss one).
From parse documentation it's suggested to use redis, and here is my problem: I don't understand how the parse's db is passed to redis' db to work properly.
Could please someone just put me on right path?
When you configure your ParseServer, there's an option to include the URL for the Redis server and set the class names for which you want to enable Live Queries:
liveQuery: {
classNames: ['_User', 'Map'],
redisURL: 'redis://localhost:6379'
}
Full setup:
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://IP:PORT/PATH',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'AppID',
masterKey: process.env.MASTER_KEY || 'MasterKey', //Add your master key here. Keep it secret!
//javascriptKey: process.env.JAVASCRIPT_KEY || '',
serverURL: process.env.SERVER_URL || 'http://IP:PORT/parse', // Don't forget to change to https if needed
liveQuery: {
classNames: ['ExampleClass'], // Add Class names here
redisURL: 'redis://REDIS_IP:REDIS_PORT'
},
});
var app = express();
var port = process.env.PORT || 1111;
var httpServer = require('http').createServer(app);
httpServer.listen(port, function() {
console.log('App on port ' + port + '.');
});
// This will enable the Live Query real-time server
ParseServer.createLiveQueryServer(httpServer, {
redisURL: 'redis://REDIS_IP:REDIS_PORT'
});
Related
I'm trying to get the parse-server password reset functionality working, but no success so far. This is my setup:
var api = new ParseServer({
databaseURI: process.env.DATABASE_URI || process.env.MONGOLAB_IVORY_URI,
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'APP_NAME',
clientKey: process.env.CLIENT_KEY || 'xxxx',
masterKey: process.env.MASTER_KEY || '',
serverURL: process.env.SERVER_URL || 'https://APP.herokuapp.com/parse',
appName : 'APP_NAME',
verifyUserEmails: true,
publicServerURL: 'https://APP.herokuapp.com/parse',
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
fromAddress: 'From Name <from#email.com>',
domain: 'https://api.mailgun.net/v3/***MY_DOMAIN***/messages',
apiKey: 'key-xxxxxxxxxx',
}
}
});
The iOS Parse SDK simply says the email is succesfully sent, but nothing arrives. Also the Mailgun logs show no sign of activity. I have tested this Mailgun setup with curl and that worked just fine.
I tried both https://api.mailgun.net/v3/MY_DOMAIN/messages and https://api.mailgun.net/v3/MY_DOMAIN
Any clue what's wrong with my setup?
Or how I can troubleshoot this remotely running Parse setup?
Ok I managed to solve it after hours of digging.
As it turns out the parse-simple-mailgun-adapter does not handle invalid Mailgun URLs.
Instead of providing https://api.mailgun.net/v3/MY_DOMAIN, I should have provided just MY_DOMAIN. Appearantly the adapter will construct the url.
this is the main config from index.js in ParseServer code:
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'myAppId',
masterKey: process.env.MASTER_KEY || 'myMasterKey', //Add your master key here. Keep it secret!
serverURL: process.env.SERVER_URL || 'http://localhost:1337', // Don't forget to change to https if needed
liveQuery: {
classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
}
As I understand it, I do not have to change any of these values. No need to hardcode my keys since I can make use of Heroku config vars:
However, I must be doing something wrong since launching my Heroku app results in a generic error:
I want to avoid the hardcoding-in-code option. Any ideas?
Heroku app logs:
I am able to run parse-server on Amazon Elastic Beanstalk and run locally the parse-dashboard with local NodeJS however Cloud Code logs does not show up even if in the settings it is configured:
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'myAppId',
masterKey: process.env.MASTER_KEY || '', //Add your master key here. Keep it secret!
fileKey: process.env.FILE_KEY || '', // Add the file key to provide access to files already hosted on Parse
serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse', // Don't forget to change to https if needed
liveQuery: {
classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
}
});
What could be missing in the configuration?
Here's the code that I am expecting to log:
Parse.Cloud.define('hello', function(req, res) {
console.log('hello method called');
res.success('Hi');
});
I can see from my sample website that the method return the correct response but logs does not show in the parse-dashboard.
Its nothing that you can do in the configuration. The CloudCode is currently not meant to be shown in the Parse Dashboard but Parse Community is working on it. See and follow that issue (https://github.com/ParsePlatform/parse-server/issues/895) and as soon its closed you might be able to view the cloude code on Parse Dashboard.
Has nobody gotten Unity SDK to work w/ self hosted Parse deployment?
If I use the prescribed code, that looks like this:
ParseClient.Initialize(new ParseClient.Configuration {
ApplicationId = "abc123",
Server = "http://exampe.ip.com/parse/"
});
i get a callstack that looks like this:
>
NullReferenceException: Object reference not set to an instance of an object
UnityEngine.WWW.FlattenedHeadersFrom (System.Collections.Generic.Dictionary`2 headers) (at C:/buildslave/unity/build/Runtime/Export/WWW.cs:118)
UnityEngine.WWW..ctor (System.String url, System.Byte[] postData, System.Collections.Generic.Dictionary`2 headers) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/UtilsBindings.gen.cs:129)
Parse.Internal.HttpClient.GenerateWWWInstance (System.String uri, System.Byte[] bytes, System.Collections.Hashtable headerTable)
Parse.Internal.HttpClient+<>c__DisplayClass10+<>c__DisplayClass16.<ExecuteAsync>b__9 ()
Parse.PlatformHooks+<RunDispatcher>d__2e.MoveNext ()
UnityEngine.Debug:LogException(Exception)
Parse.<RunDispatcher>d__2e:MoveNext()
What am I missing?
I've debugged this and its due to a null value for the windowskey (aka ClientKey). Alter your initialization code to be the following and it should work:
ParseClient.Initialize(new ParseClient.Configuration {
ApplicationId = "abc123",
Server = "http://exampe.ip.com/parse/",
WindowsKey = '' //<== specify an empty string
});
in index.js:
....
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'myAppId',
masterKey: process.env.MASTER_KEY || 'myMasterKey', //Add your master key here. Keep it secret!
serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse', // Don't forget to change to https if needed
clientKey: '', <=== possibly not needed, just to be sure
liveQuery: {
classNames: ["Scores", "Posts", "Comments"] // List of classes to support for query subscriptions
}
});
I'm setting up a local Parse Server: https://github.com/ParsePlatform/parse-server
I'm setting my keys as per the link above yet still getting 'Unauthorised'. Any ideas why this is?
Here's the snippet where I create the server var:
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var app = express();
var port = process.env.PORT || 1337;
// Specify the connection string for your mongodb database
// and the location to your Parse cloud code
var api = new ParseServer({
databaseURI: 'mongodb://localhost:27017',
cloud: '/Users/jack/Desktop/dev/node_modules/parse-server/lib/cloud/main.js', // Provide an absolute path
appId: 'jack1234',
masterKey: 'jack1234',
serverURL: 'http://localhost:' + port + '/parse'
});
// Serve the Parse API on the /parse URL prefix
app.use('/parse', api);
// Hello world
app.get('/', function(req, res) {
res.status(200).send('Express is running here.');
});
app.listen(port, function() {
console.log('parse-server-example running on port ' + port + '.');
});
Here's a screenshot of the Unauthorised:
You need to wirte the value in the header without '' (Apostrophe).
like:
X-Parse-Application-Id : jack1234
I think the issue might be from the headers you are sending to the ending. this is why you get the 403 code. I'm guessing the server does not recognize requests with these headers.
// Serve the Parse API on the /parse URL prefix
app.use('/parse', api);
On this line shown above you are injecting the arguments in which the express app needs to be authenticated with. So why not just make a request to it without the Headers ?