AWS Elastic Beanstalk Server URL for iOS Application
I've created an instance of Parse-Server on AWS, but I am unable to get my iOS app linking with the server. I was successful with Heroku, but not so far with AWS.
When I navigate to my environment URL (http://parseserver-7nebu-env.us-east-1.elasticbeanstalk.com), I get "I dream of being a web site", which is correct.
I've set up my environment variables including my mLab URI.
I used the following server url in my iOS implementation:
[Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id<ParseMutableClientConfiguration> configuration) {
configuration.applicationId = @"app_id";
configuration.clientKey = @"client_key";
//configuration.server = @"https://my-app-name.herokuapp.com/parse"; // Heroku instance
configuration.server = @"https://app-name-env.us-east-1.elasticbeanstalk.com/parse"; // Amazon Web Services instance
}]];
No luck so far.
Any suggestions?
Thanks
Can you say what error messages you are seeing? Are there any logs on the server? Are you using the same client key and app id as on Heroku?
Sure. I am seeing different errors depending on what URL I have tried:
https://parseserver-7nebu-env.us-east-1.elasticbeanstalk.com/parse - This URL just hangs and times out with the message: [Error]: The request timed out. (Code: 100, Version: 1.12.0)
http://parseserver-7nebu-env.us-east-1.elasticbeanstalk.com/parse - [Error]: {"code":1,"message":"Internal server error."} (Code: 1, Version: 1.12.0)
parseserver-7nebu-env.us-east-1.elasticbeanstalk.com/parse -[Error]: unsupported URL (Code: 100, Version: 1.12.0)
http://parseserver-7nebu-env.us-east-1.elasticbeanstalk.com - [Error]: Failed to run command eventually with error: Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}
https://parseserver-7nebu-env.us-east-1.elasticbeanstalk.com - This just hangs and times out with message: [Error]: The request timed out. (Code: 100, Version: 1.12.0)
And yes, I am using the same client key and app id as with Heroku.
Thanks
The correct format is with a / at the end of the URL for iOS.
https://parseserver-7nebu-env.us-east-1.elasticbeanstalk.com/parse/
@harrygt thanks for the response, but this didn't work for me either. It timed out.
Ok sorry can you try without https. Just:
http://parseserver-7nebu-env.us-east-1.elasticbeanstalk.com/parse/
The problem I think is that you can't request a certificate for Elastic Beanstalk, we had to use a custom domain so that the certificate was valid and therefore visiting it over https works. If http works as above then I think that is your issue.
@harrygt nope :( [Error]: {"code":1,"message":"Internal server error."} (Code: 1, Version: 1.12.0)
Doing some googling, the general pattern is that it's something to do with MongoDB replicasets? (I don't know what that means!)
Hmm. Ok do you have the following setup in your environment variables:
- APP_ID = appid
- DATABASE_URI = mongodb://###
- MASTER_KEY = masterkey
- NODE_ENV = production
- PARSE_MOUNT = /parse
As for mlab.com did you export and import the data via mongoimport or did you hit the migrate button on parse.com?
I used the migrate tool in Parse. Would having a sandbox mLab collection and a production server instance be the issue? Just thinking out loud.
And yeah, all my environment variables are setup.
Thanks
Hmm no thats what we have running so no issues there.
Have you downloaded the Elastic Beanstalk CLI? If not, download that and do:
eb init eb labs download When you've made your changes then do eb deploy
In the index.js file you should have the following setup correctly:
databaseURI: 'mongodb://####', cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js', appId: '###', masterKey: '###', fileKey: '###', serverURL: 'http://###.elasticbeanstalk.com/parse', filesAdapter: if needed
Ok, will do that and let you know. Thank you!
No luck unfortunately.
My index.js is:
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var databaseUri = process.env.DATABASE_URI || process.env.MONGOLAB_URI
if (!databaseUri) {
console.log('DATABASE_URI not specified, falling back to localhost.');
}
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://user:[email protected]:39155/db-name',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || '642k4TTqGk1mOVzIrlTyRgfNlCd5VJ26NtciiC66',
fileKey: process.env.FILE_KEY || '2b70984c-83be-4c6c-a90f-4f71c9f3c64a',
masterKey: process.env.MASTER_KEY || 'muH3zkWCHTKsxi3LRLTjiFaF2VpPqn7PzMNRbjwv',
serverURL: 'http://parseserver-7nebu-env.us-east-1.elasticbeanstalk.com/parse'
});
// Client-keys like the javascript key or the .NET key are not necessary with parse-server
// If you wish you require them, you can set them as options in the initialization above:
// javascriptKey, restAPIKey, dotNetKey, clientKey
var app = express();
// Serve the Parse API on the /parse URL prefix
var mountPath = process.env.PARSE_MOUNT || '/parse';
app.use(mountPath, api);
// Parse Server plays nicely with the rest of your web routes
app.get('/', function(req, res) {
res.status(200).send('I dream of being a web site.');
});
var port = process.env.PORT || 1337;
app.listen(port, function() {
console.log('parse-server-example running on port ' + port + '.');
});
Check your heroku server logs after making these requests and let us know what they say.
I'm using AWS, not Heroku..?
Silly me.... Just ignore that word. Check your server logs when making these requests and see what they say.
Did you solve this problem?
Second that. Stuck too.
i had also same problem ,here is my log The request timed out. (Code: 100, Version: 1.12.0) Network connection failed. Making attempt 4 after sleeping for 11.349660 seconds.
For me there were two issue that fixed this:
- if it shows as timed out - make sure you are passing http, not https. https needs more stuff to do in aws
- make sure you are passing correct mongoDB URI. I left it with one space inside and it was returning internal error for me.
Good luck!
@nickjf89 @drew-gross @harrygt @ShawnBaek [Error]: unsupported URL (Code: 100, Version: 1.14.2) i got this error after migration from parse to MLab+Heroku for downloading images and uploading images.please could you help me out