parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

Ios Swift Error 3840 when trying to point client to Parse server on Heroku

Open rendragon83 opened this issue 10 years ago • 10 comments

I am having a problem when trying to point my client to the Parse Server. I am 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?

rendragon83 avatar Mar 24 '16 20:03 rendragon83

try : $0.server = "https://MyAppName.herokuapp.com/parse/"

flovilmart avatar Mar 26 '16 13:03 flovilmart

Add this to Exception Domains in info.plist

    <key>herokuapp.com</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
            <false/>
        </dict>

andreiurzica avatar Mar 26 '16 16:03 andreiurzica

@flovilmart I tried this buy I get the same result. @andreiurzica When I tried to enter this into the info.plist it just crashed.

rendragon83 avatar Mar 28 '16 17:03 rendragon83

how did you configure parse-server?

flovilmart avatar Mar 31 '16 23:03 flovilmart

This appears to be a client SDK issue unrelated to Parse Server. Please look for the relevant repository on GitHub for this SDK and consider opening an issue there.

A list of Parse's open source repositories is available at parseplatform.github.io

You may use Server Fault for questions about managing Parse Server.

For code-level and/or implementation-related questions or technical support, please refer to Stack Overflow.

hramos avatar Apr 02 '16 01:04 hramos

I got it working. I wasn't setting up my Parse Server correctly. I was following the migration guide, but I didn't get the index.js file set up correctly. I found that the steps from the answer to this stackoverflow helped out a lot. http://stackoverflow.com/questions/35389389/how-can-i-host-my-own-parse-server-on-heroku-using-mongodb I figured I would post these here incase anyone else has the same issue.

rendragon83 avatar Apr 06 '16 19:04 rendragon83

I'm still seeing this error with iOS SDK 1.13 and Parse server 2.2.9. The server works fine from js and from Android, but I get this error from any call from iOS: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo=XXXXXXXXX {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}

oproulx avatar May 13 '16 20:05 oproulx

I'm seeing this error as well. @rendragon83 What exactly did you fix in your index.js file? @oproulx Did you resolve this in the end?

craiggrummitt avatar Jun 16 '16 22:06 craiggrummitt

Hey @craiggrummitt I think I ended up reinstalling the server completely (created a new instance). I think something was corrupt with my first installation.

oproulx avatar Jun 17 '16 13:06 oproulx

What I discovered was that this obscure error message is indicating that the data being returned from Heroku wasn't correctly formatted JSON, in my case I discovered this was because heroku was returning an error (I had used my login credentials for Mongo in the Mongo database URL, rather than the mongo database credentials). I discovered the nature of this error by typing heroku logs in terminal.

craiggrummitt avatar Jun 17 '16 21:06 craiggrummitt