Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't connect to remote parse server on iOS (local works) #1341

Closed
markuswinkler opened this issue Apr 2, 2016 · 13 comments
Closed

Can't connect to remote parse server on iOS (local works) #1341

markuswinkler opened this issue Apr 2, 2016 · 13 comments

Comments

@markuswinkler
Copy link

I have a rather strange issue, I can perfectly fine connect to my local parse-server instance but not to the remote one on iOS.
I always get this error upon facebook login:

[Error]: {
    code = 100;
    message = "XMLHttpRequest failed: \"Unable to connect to the Parse API\"";
} (Code: 141, Version: 1.13.0)

This are my connection settings, first one always works, second one always fails:

if SystemSettings.instance.localServer {
     let configuration = ParseClientConfiguration {
            $0.applicationId = ParseID
            $0.clientKey = ParseKey
            $0.server = "http://10.0.1.30:1337/parse"
     }
     Parse.initializeWithConfiguration(configuration)
} else {
     let configuration = ParseClientConfiguration {
            $0.applicationId = ParseID
            $0.clientKey = ParseKey
            $0.server = "http://xxxxxxxxxx.us-east-1.elasticbeanstalk.com/parse"
     }
    Parse.initializeWithConfiguration(configuration)
}           

Note: doesn't matter if the url ends with "parse/" or "parse".
Note 2: The elastic beanstalk environment is an exact mirror of the local installation.
Note 3: serverURL is set on both

To add insult to injury, parse dashboard works perfectly fine for BOTH settings.
A cURL test call also works perfectly fine.
This is really odd.

@flovilmart
Copy link
Contributor

Can you access it through CURL?

@markuswinkler
Copy link
Author

Yes, that's why it is so odd. cURL, parse dashboard, both work.

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>

is also set.

@flovilmart
Copy link
Contributor

Sorry, I just noticed you wrote that already. that's only affecting the Facebook login right? all other calls are working properly?

@markuswinkler
Copy link
Author

well, I can't make any other call from inside the iOS without logging in first.

@flovilmart
Copy link
Contributor

alright, that's odd indeed... Can you run the server in verbose? setting VERBOSE=1 and see if the call gets to it. Otherwise that may indicate a problem in the iOS SDK

@markuswinkler
Copy link
Author

what's the cURL equivalent of that call? I think it really is a iOS issue since dashboard connects fine and I can do everything (modify entries and such).

@flovilmart
Copy link
Contributor

Check the REST documentation here: https://www.parse.com/docs/rest/guide#users-linking-users

@markuswinkler
Copy link
Author

Yes, that worked, returned the full user. Really strange.

Using Parse (1.13.0)
Using ParseFacebookUtilsV4 (1.11.1)

@markuswinkler
Copy link
Author

I was able to track it down a little bit further via
http://blog.parse.com/announcements/parse-debugging-tools-identify-client-side-issues-faster/

It's weird from the start.
e.g. the automatic parse query for installations at the beginning
http://localhost:1337/parse/classes/_Installation
works in iOS on localhost, fails right away on remote with error 400 before even logging in.
and if make the same call to the remote server via cURL it works.

Very simple test cloud functions that work on localhost and via cURL fail to execute on remote (internal server error).

Both installations (localhost and remote) point to the same MongoDB instance on mLab and use the same DB user. Based on my local testing and the remote cURL testing everything should work.

@flovilmart
Copy link
Contributor

Can your provide the server VERBOSE logs?

Also, what's the body received when you have the status 400?
400 is the HTTP Status code we set for all Parse.Error.

Error 141 is related to triggers, do you have beforeSave or afterSave hooks set?

@markuswinkler
Copy link
Author

FOUND IT!!!!
Elastic beanstalk uses a nginx reverse proxy to access parse. changing the server_url from
http://localhost:1337/parse
to
http://localhost/parse
did the trick!

That also explains why direct cURL calls worked and cloud code functions didn't.
The cloud code functions tried to query additional data from the sever and the internal requests always timed out since it couldn't reach the server, hence the weird errors.

@flovilmart
Copy link
Contributor

alright :) nice!

@farshadj
Copy link

Nice. Changing http://localhost:1337/parse to http://localhost/parse did the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants