Hello Friends,
I've migrated the parse-server code on my aws ec2 server. Before testing to my code, I've tried to connect to parse server as mentioned below.
Parse.initializeWithConfiguration(ParseClientConfiguration(block: { ( configuration : ParseMutableClientConfiguration ) -> Void in
configuration.applicationId = PARSE_DEVELOPMENT_APPLICATION_ID
configuration.clientKey = PARSE_DEVELOPMENT_CLIENT_KEY
configuration.server = "https://api.parse.com"
}))
I have used Parse (1.12.0) SDK in this App.
When I start my iOS App, I'm getting following error message.
2016-02-02 12:42:59.684 MyParseApp[5101:61497] [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.}
Could you assist me here what is wrong ? Any suggestion/assistance would be highly appreciated.
Thank you.
This is pointing at api.parse.com instead of a parse-server instance, but I'm curious if @nlutsenko sees anything else strange here.
Thank you Fosco for quick reply.
I've migrated the code to my aws ec2 server and database on mongolab.
Using curl, I'm able to call the cloud function, insert data in mongodb, get data from mongodb.
But in iOS(Swift) App, I'm getting following error message :
2016-02-02 11:39:59.718 MyApp[4168:43783] [Error]: schema mismatch for _Session.createdWith; expected map but got object (Code: 111, Version: 1.12.0)
error in register : schema mismatch for _Session.createdWith; expected map but got object
is it different issue ?
Few things:
createdWith property on the _Session. Looks like at some point it received a map, instead of a Parse Object and now it fails to validate since the schema is already set. I would recommend taking a look at the _Session collection object schema and making the adjustment either on the server or on the client.Hope this helps, let us know if there is anything we missed or anything that is not quite clear.
Hi Nikita, thank you very much for your quick reply.
Regarding second issue, this class/collection _Session is part of my Parse Application and generated by Parse. Actually I've migrated this data from Parse to Mongodb hosted on MongoLab.
"createdWith" : {
"action" : "login",
"authProvider" : "password"
}
I've not done any manual changes in _Session schema. Is this schema mismatch issue because of database migration from parse to mongodb ?
Adding /parse to the end of my configuration.server url worked for me.
Hi @latne1ec , Thank you for your reply.
Could you share more details about which platform you have used for parse deployment ?
I've used heroku and mongolab.
I've also added /parse to the end of my configuration.server url.
I set up an ec2 instance on aws to host my mongodb database and heroku for the parse-server api.
@gfosco isn't the API URL for parse https://api.parse.com/1/
I had the same problem and added parse at the end of the server URL and it worked. Thank you latne1ec!!!!
/parse at the end of the url worked for me too.
I added /parse and it is not working for me. I have the same issues as @jaydeep82, I am also using Heroku with mongolab. I have tried two different ways to do this in swift, but I still get the same error. These are the two ways I have done it:
let configuration = ParseClientConfiguration(block: {
(ParseMutableClientConfiguration) -> Void in
ParseMutableClientConfiguration.applicationId = "appID"
ParseMutableClientConfiguration.clientKey = "appMasterKey"
ParseMutableClientConfiguration.server = "https://MyAppName.herokuapp.com/parse"
})
Parse.initializeWithConfiguration(configuration);
and I also tried:
let configuration = ParseClientConfiguration {
$0.applicationId = "appID"
$0.clientKey = "appMasterKey"
$0.server = "https://MyAppName.herokuapp.com/parse"
}
Parse.initializeWithConfiguration(configuration)
Both ways I still get error code of 3840 "JSON text did not start with array or object and option to allow fragments not set."
2016-03-24 11:20:31.538 ClockIn[4668:676920] Warning: A long-running operation is being executed on the main thread.
Break on warnBlockingOperationOnMainThread() to debug.
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.}
Either of these work if I use https://api.parse.com/1/ for the server, but does not work if I try to use my own server. Does anyone know why this is happening, or is it just broken when using iOS and swift?
I just tried migrating my app to Heroku. Some things work, others do not. I am getting the error "JSON text did not start with array or object and option to allow fragments not set" when saving objects.
My app is configured using:
[Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id
configuration.applicationId = @"xxxxx";
//configuration.clientKey = @"";
configuration.server = @"http://myappname.heroku.com/parse";
}]];
It all works fine when pointing to the parse servers
Any help? Suggestions?
I am now getting the same issue as @bchapin
Can you open a new issue and include some logs for what exactly is happening? We can't debug with such a vague description.
Is there a new issue for this ? I am facing the same issue and pretty much stuck .. Is there a solution for this ?
Exact same issue for me as @rendragon83 , competely stuck. If anyone managed to sort this please comment.
Any solution for this will be greatly appreciated ,,, we are stuck
+1 Got the same problem. But with PFCloud.callFunctionInBackground()
Getting the same problem. I have parse installed on AWS Elastic Bean Stalk with database on mLab.
This happens very randomly.
2016-05-02 09:43:43.631 app[1387:388806] [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.}
2016-05-02 09:43:43.694 app[1387:388806] [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.}
2016-05-02 09:43:43.755 app[1387:388806] [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.}
Here are the error logs from the server
/var/log/nginx/error.log
2016/05/02 13:42:15 [error] 3188#0: *142495 recv() failed (104: Connection reset by peer) while reading response header from upstream, client:
, server: , request: "POST /parse/classes/Comment HTTP/1.1", upstream: "http://127.0.0.1:8081/parse/classes/Comment", host: "api.snapchat.com" 2016/05/02 13:42:15 [error] 3188#0: *142486 recv() failed (104: Connection reset by peer) while reading response header from upstream, client:
, server: , request: "POST /parse/classes/SoundData/l8Kkl0B3NK HTTP/1.1", upstream: "http://127.0.0.1:8081/parse/classes/SoundData/l8Kkl0B3NK", host: "hidden-prefix.us-east-1.elasticbeanstalk.com" 2016/05/02 13:42:18 [error] 3188#0: *142486 connect() failed (111: Connection refused) while connecting to upstream, client:
, server: , request: "POST /parse/classes/Comment HTTP/1.1", upstream: "http://127.0.0.1:8081/parse/classes/Comment", host: "api.snapchat.com" 2016/05/02 13:42:19 [error] 3188#0: *142517 connect() failed (111: Connection refused) while connecting to upstream, client:
, server: , request: "POST /parse/functions/FeedCloudFunction_getFeedOfUser HTTP/1.1", upstream: "http://127.0.0.1:8081/parse/functions/FeedCloudFunction_getFeedOfUser", host: "api.snapchat.com" 2016/05/02 13:42:33 [error] 3188#0: *142508 upstream prematurely closed connection while reading response header from upstream, client: 10.180.203.86, server: , request: "POST /parse/classes/SoundData/3NbbVRJIIo HTTP/1.1", upstream: "http://127.0.0.1:8081/parse/classes/SoundData/3NbbVRJIIo", host: "hidden-prefix.us-east-1.elasticbeanstalk.com"
2016/05/02 13:42:33 [error] 3188#0: *142508 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 10.180.203.86, server: , request: "POST /parse/classes/SoundData/3NbbVRJIIo HTTP/1.1", upstream: "http://127.0.0.1:8081/parse/classes/SoundData/3NbbVRJIIo", host: "hidden-prefix.us-east-1.elasticbeanstalk.com"
2016/05/02 13:42:33 [error] 3188#0: *142508 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 10.180.203.86, server: , request: "POST /parse/classes/SoundData/3NbbVRJIIo HTTP/1.1", upstream: "http://127.0.0.1:8081/parse/classes/SoundData/3NbbVRJIIo", host: "hidden-prefix.us-east-1.elasticbeanstalk.com"
2016/05/02 13:43:01 [error] 3188#0: *142550 upstream prematurely closed connection while reading response header from upstream, client:
, server: , request: "GET /parse/classes/_User/ihSR4oZH5i HTTP/1.1", upstream: "http://127.0.0.1:8081/parse/classes/_User/ihSR4oZH5i", host: "api.snapchat.com" 2016/05/02 13:43:01 [error] 3188#0: *142552 upstream prematurely closed connection while reading response header from upstream, client:
, server: , request: "POST /parse/classes/_User/p8WZn7NLL6 HTTP/1.1", upstream: "http://127.0.0.1:8081/parse/classes/_User/p8WZn7NLL6", host: "hidden-prefix.us-east-1.elasticbeanstalk.com" 2016/05/02 13:43:01 [error] 3188#0: *142562 upstream prematurely closed connection while reading response header from upstream, client: 10.180.203.86, server: , request: "POST /parse/config HTTP/1.1", upstream: "http://127.0.0.1:8081/parse/config", host: "hidden-prefix.us-east-1.elasticbeanstalk.com"
I am getting the same error after moving the mandrill initializer to the top of the cloud code:
Error loggin in: 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.}
// Use Parse.Cloud.define to define as many cloud functions as you want.
// For example:
var Mandrill = require('mandrill-api/mandrill');
Mandrill.initialize('XXXXXXXXXXXXXXXXXXXXX');
Parse.Cloud.define("hello", function(request, response) {
response.success("Hello world!");
});
Parse.Cloud.define("sendMail", function(request, response) {
// Moved this line to the top
// var Mandrill = require('mandrill-api/mandrill');
// Mandrill.initialize('XXXXXXXXXXXXXXXXXXXXX');
Mandrill.sendEmail({
message: {
text: request.params.text,
subject: request.params.subject,
from_email: request.params.fromEmail,
from_name: request.params.fromName,
to: [
{
email: request.params.toEmail,
name: request.params.toName
}
]
},
async: true
},{
success: function(httpResponse) {
console.log(httpResponse);
response.success("Email sent");
},
error: function(httpResponse) {
console.error(httpResponse);
response.error("Email not sent");
}
});
});
Before that I was getting:
when calling the sendMail function
I am Also got the same issues in JSON parisng.i am new to swift code so i don't know how to fix this issues. please help me to fix this issues
"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.}"
when i call cloud function from Xcode, getting following result
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.}
@wellkeptbeauty can you open a new issue with all required details?
@wellkeptbeauty same here, how did you fix?
I've been stuck for 3 weeks with this problem. It happens when I call saveInBackgroundWithBlock in parse ios sdk. I get the same connection refused in my logs as candork does. I am desperate to fix this. Our app is completely blocked. It's completely random and I cannot reproduce it using any steps. Sometimes it fails, sometimes it doesn't. It appears to only happen in ios11. There is no change in ios code and it has been working fine for 2 years, then all of a sudden....
@ArchonLight If you can provide details/logs of the _specific_ request causing the error, and any relevants logs server side, that would be most helpful.
This is likely to be caused by a 5xx error on the server, or an uncaught exception that would make the error not being properly set in the response. OR a response from a proxy, that terminated the connection without responding with a JSON response.
My object to save in mongoDB:
Printing description of photo:
<Photo: 0x1c08d4a50, objectId: new, localId: (null)> {
city = Powell;
imageUrl = "http://res.cloudinary.com/xxxxxxxx/image/upload/v1509739983/dnx04b374qe0khgru1rh.jpg";
likes = 0;
trip = "<Trip: 0x1c0eaba00, objectId: jAcW7QEIsu, localId: (null)>";
tripName = "Test again";
user = "<PFUser: 0x1c02e3e80, objectId: mzITFRYJjy, localId: (null)>";
userName = xxxxxxxxx;
usersWhoHaveLiked = (
);
}
my ios code:
[photo saveInBackgroundWithBlock:^(BOOL succeeded, NSError * _Nullable error) {
if(error) {
NSLog(@"Parse save failure...");
completionBlock(nil, error, photo);
}else {
NSLog(@"Parse save success...");
completionBlock(YES, nil, photo);
}
}];
Console Error:
[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.}
AWS EB log errors:
2017/10/20 03:43:01 [warn] 3513#0: duplicate MIME type "text/html" in /etc/nginx/sites-enabled/elasticbeanstalk-nginx-docker-proxy.conf:11
2017/10/20 20:52:55 [error] 16663#0: *60670 upstream prematurely closed connection while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: , request: "POST /parse/classes/Activity HTTP/1.1", upstream: "http://xxx.xxx.xxx.xxx:8080/parse/classes/Activity", host: "api.xxxxxxxxxxxx.com"
2017/10/20 20:52:55 [error] 16663#0: *60670 connect() failed (111: Connection refused) while connecting to upstream, client: xxx.xxx.xxx.xxx, server: , request: "POST /parse/classes/Activity HTTP/1.1", upstream: "http://xxx.xxx.xxx.xxx:8080/parse/classes/Activity", host: "api.xxxxxxxxxxx.com"
2017/10/20 20:52:55 [error] 16663#0: *60712 connect() failed (111: Connection refused) while connecting to upstream, client: xxx.xxx.xxx.xxx, server: , request: "POST /parse/classes/Photo HTTP/1.1", upstream: "http://xxx.xxx.xxx.xxx:8080/parse/classes/Photo", host: "api.xxxxxxxx.com"
^ and a bunch more just like it
what about your parse-server logs? did the process crash?
Because: 60670 connect() failed (111: Connection refused) while connecting to upstream
Is it always marked first by upstream prematurely closed connection while reading response header from upstream, with the following connections refused? That does seem a lot like a crash :/. It would definitely help to see the corresponding parse-server logs.
Most helpful comment
Adding /parse to the end of my configuration.server url worked for me.