-
Notifications
You must be signed in to change notification settings - Fork 299
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
CBLReplication error: strange URL in the error message. #1135
Comments
I've never seen a problem like that before — very weird. The URL is definitely mangled. Please turn on logging for Are you sure there isn't some new server-side configuration that could be causing this, like a redirect rule? Because the domain it's hitting is |
I'm sure there is no new server-side configuration, because if I go back to the branch with the old version of couchbase-lite (1.1) everything works fine |
this is the log file till the first time I get an error, if I go on it will keep doing stuff and then I'll reach another error. |
The error shows up at the end of the log:
|
Yes and the URL ( |
So today I was able to do more tests, and also check the logs on the server (it's CouchDB 1.6.1). I also started from scratch and instead of using my app, I checked out the GrocerySync Demo app, I changed database name and the server DB URL. Moreover I added a basic authenticator:
These are the only changes made to the GrocerySync app. The behavior is identical to what I reported before, every seconds there is an error (and the alert shows up). The error says that the server with the specified hostname could not be found and if I check the URL inside the NSError I see a weird URL:
Then I checked the logs on the server and they look like this:
The weird thing to notice is that is always trying first to do requests without authentication and then it try the same request using authentication. Also, the same does not happen using couchbase-lite 1.1. One more thing, the Android app using couchbase-lite 1.2 works properly and also doesn't make all these requests (unauthenticated and authenticated ones). |
What you have seen is what is described in #1127 which turns out to be an CFNetwork bug. @snej have a workaround implemented in |
that explains the multiple requests with and without authentication, but not the errors, right? :( |
Yes, that's not the error. From https://gist.github.com/lucatorella/96524767f5bf6cb105cd#file-replication-log-L352, it seems like the URL path is escaped correctly. I did a quick test by doing the same thing as the CBLRestPuller does and the error contains the correct URL. I'm not sure what triggered the invalid URL for your case.
Error has correct URL:
|
@pasin by |
In your app, if you turn off authentication, does the bug go away? I think the screwed up hostname may be a symptom of #1124, which is a nastier manifestation of the CFNetwork bug Pasin mentioned; we've seen some weird stuff in packet traces, where it looks as though CFNetwork gets mixed up at the TCP stream level. We have a fix for these issues, on a branch |
I compiled the library from the |
Here's why I'm stumped: All of the requests sent by a replicator use the same hostname. And that problematic request gets sent correctly once and gets a 401 response; it's the second attempt, with the credentials, that fails. But NSURLConnection doesn't change the URL when it retries a request after authentication, so there's no way it should be hitting a different hostname. Something to try: Use
(The response may include binary data, so I redirect it to a file.) Also, as I asked earlier, could you temporarily turn off authentication on the server and retry? Thanks. |
the response is:
At the moment I can't temporarily turn off authentication. I'll see what I can do. But why all requests are tried without authentication first? That sounds like a bug |
I forgot to say that you should authenticate the request. Add args
Yes, #1127, as Pasin said above. |
so response is:
|
would it help if I can give you the GrocerySync app modified with our endpoints? There it's reproducible 100% of the times |
If you can give me a login to your server, I probably don't need any code; I can just use LiteServ to run a pull replication from it. You can send the credentials to jens at couchbase. |
Got the credentials; thanks! I'm able to reproduce the bug by using LiteServ to pull the database. Now I can investigate… |
that's great, good luck and thanks for looking into this 👍 |
The server is returning a redirect (301 status) to the bogus URL. I see the NSURLSession delegate call happening in the app (though it doesn't log anything -- need to fix that, it would have made diagnosing this easier), and I can reproduce it using It looks like CouchDB wants to change the “%2F” in the URL into a “/“ so it redirects to that path, but the hostname in the URL gets mangled on the way back to the client. I suspect something is misconfigured on your nginx server.
|
This would have helped diagnose #1135 much more easily -- the problem ended up being server-side, with a bogus hostname in the redirected URL.
Thanks for the feedback. I checked and yes, there was a bug in nginx which has been fixed. Anyway there is another issue here. The URL couchbase is trying is I tried with the latest nightly build and the issue is still there. Now the redirection works, but you can save some requests by fixing the This is part of the log coming from the server:
|
To be honest, since it only occurs with design documents, and only with CouchDB, it's not going to be a priority to change it. |
I'm trying to update to couchbase 1.2 (with ForestDB), I've updated the pod and luckily I didn't have to change any line and it just compile. Anyway I'm receiving a lot of weird error.
The code I have is quite simple:
https://mydata.mydomain.com/databaseName
kCBLReplicationChangeNotification
notifications(same thing for push replication).
With version 1.1.1 I don't get any error, but now I get tons of notification where
replication?.lastError
errorInfo
is:As you can see it can't find some hostnames, and the URLs are clearly messed up. But I've no idea where it get's those URLs.
If for instance I change the initial URL to a wrong one like
https://mydata.mydomain.com/fakeDatabaseName
then I receive the error I'd expect, with the URL I used:Any idea what's going on?
The text was updated successfully, but these errors were encountered: