//Start the HTTP server and publish a bonjour service
CBLManager* manager = [CBLManager sharedInstance];
CBLListener *_listener = [[CBLListener alloc] initWithManager: manager port: 0];
_listener.readOnly = YES; // Do this to prevent writes to your databases
_listener.passwords = @{@"naomi": @"letmein"};
[_listener setBonjourName: [UUID generateUUID] type: @"_myservice._tcp"];
BOOL ok = [_listener start];
//start bonjour client to listen for peers
serviceBrowser = [[NSNetServiceBrowser alloc] init];
[serviceBrowser setDelegate:self];
[serviceBrowser searchForServicesOfType:@"_myservice._tcp" inDomain:@""];
Continuous Pull replication creation on service resolution
NSString *peerDB = [NSString stringWithFormat:@"http://%@:%@@%@:%d/mydb/",@"naomi",@"letmein",netService.hostName,netService.port];
NSURL *peerURL = [NSURL URLWithString:peerDB];
CBLReplication *syncPullRepl = [self.database pullFromURL:peerURL];
syncPullRepl.continuous = YES;
syncPullRepl.persistent = NO;
[syncPullRepl start];
Pointing Safari on my Mac on the same wifi network at the constructed URL
http://naomi:let...@myipad.local.:53548/mydb
gives
{ "doc_count" : 52, "db_name" : "mydb", "disk_size" : 28096002, "update_seq" : 66, "db_uuid" : "BD3FD33F-1E8C-4459-864E-2F14DD479258" }
Console log
17:58:35.582| Sync: CBL_Puller[http://naomi:let...@myipad.local.:53563/mydb/] STARTING ...17:58:35.583| CBLBasicAuthorizer initWith <http://naomi:letmein@myipad.local.:53563/mydb/>17:58:35.600| Sync: CBL_Puller[http://naomi:letmein@myipad.local.:53563/mydb/]: Reachability state = <myipad.local.>:reachable (20002)17:58:35.601| Sync: CBL_Puller[http://naomi:letmein@myipad.local.:53563/mydb/]: Going online17:58:35.969| Sync: CBL_Puller[http://naomi:letmein@myipad.local.:53563/mydb/]: Replicating from lastSequence=(null)17:58:50.426| WARNING*** : CBLSocketChangeTracker[0x1edd6bd0 mydb]: Can't connect, giving up: Error Domain=NSURLErrorDomain Code=-1005 "The operation couldn’t be completed. (NSURLErrorDomain error -1005.)"17:58:50.431| Sync: CBL_Puller[http://naomi:letmein@myipad.local.:53563/mydb/]: ChangeTracker stopped; error=Error Domain=NSURLErrorDomain Code=-1005 "The operation couldn’t be completed. (NSURLErrorDomain error -1005.)"I can't find the meaning of error 1005, not sure how to debug this through.Andy
22:44:46.283| CBLListener: Login attempted for user 'naomi'
22:44:46.284| CBLListener: GET /mydb/_local/0dfd3196fdb264858e5024f18e9523ec652d2124
22:44:46.285| CBLListenerVerbose: Response[GET /mydb/_local/0dfd3196fdb264858e5024f18e9523ec652d2124]: Starting...
22:44:46.286| CBLListenerVerbose: Response[GET /mydb/_local/0dfd3196fdb264858e5024f18e9523ec652d2124]: Returning from -init
22:44:46.288| CBLListenerVerbose: Response[GET /mydb/_local/0dfd3196fdb264858e5024f18e9523ec652d2124] answers delayResponseHeaders=1
22:44:46.293| CBLListener: Response[GET /mydb/_local/0dfd3196fdb264858e5024f18e9523ec652d2124] --> 404
22:44:46.293| CBLListenerVerbose: Response[GET /mydb/_local/0dfd3196fdb264858e5024f18e9523ec652d2124] adding 34 bytes
22:44:46.293| CBLListenerVerbose: Response[GET /mydb/_local/0dfd3196fdb264858e5024f18e9523ec652d2124] Finished!
22:44:46.293| CBLListenerVerbose: Response[GET /mydb/_local/0dfd3196fdb264858e5024f18e9523ec652d2124] prettifying response body
22:44:46.294| CBLListenerVerbose: Response[GET /mydb/_local/0dfd3196fdb264858e5024f18e9523ec652d2124] answers delayResponseHeaders=0
22:44:46.294| CBLListenerVerbose: Response[GET /mydb/_local/0dfd3196fdb264858e5024f18e9523ec652d2124] answers isChunked=0
22:44:46.295| CBLListenerVerbose: Response[GET /mydb/_local/0dfd3196fdb264858e5024f18e9523ec652d2124] answers status=404
22:44:46.295| CBLListenerVerbose: Response[GET /mydb/_local/0dfd3196fdb264858e5024f18e9523ec652d2124] answers httpHeaders={2 headers}
22:44:46.295| CBLListenerVerbose: Response[GET /mydb/_local/0dfd3196fdb264858e5024f18e9523ec652d2124] sending 46 bytes
22:44:46.296| CBLListenerVerbose: Response[GET /mydb/_local/0dfd3196fdb264858e5024f18e9523ec652d2124] answers isDone=1
22:44:46.296| CBLListenerVerbose: Response[GET /mydb/_local/0dfd3196fdb264858e5024f18e9523ec652d2124] sending nil bytes
Would the 404 response manifest as the CBLSocketChangeTracker error on the client side?
I know there is an issue against CBL _local document access but I thought this was provided by the REST API (CBLListener?)
Andy
Last Exception Backtrace:
0 CoreFoundation 0x3257129e __exceptionPreprocess + 158
1 libobjc.A.dylib 0x3925397a objc_exception_throw + 26
2 CoreFoundation 0x325711c0 +[NSException raise:format:] + 100
3 Foundation 0x38c17a98 _writeJSONValue + 644
4 Foundation 0x38c19672 ___writeJSONArray_block_invoke_0 + 102
5 CoreFoundation 0x3256599c __NSArrayEnumerate + 392
6 CoreFoundation 0x324c7b66 -[NSArray enumerateObjectsWithOptions:usingBlock:] + 58
7 Foundation 0x38c195b4 _writeJSONArray + 232
8 Foundation 0x38c17a28 _writeJSONValue + 532
9 Foundation 0x38c19776 ___writeJSONObject_block_invoke_0 + 230
10 CoreFoundation 0x3256e62a __NSDictionaryEnumerate + 710
11 Foundation 0x38c193f8 _writeJSONObject + 508
12 Foundation 0x38c179f4 _writeJSONValue + 480
13 Foundation 0x38c177de -[_NSJSONWriter dataWithRootObject:options:error:] + 122
14 Foundation 0x38c186d4 +[NSJSONSerialization dataWithJSONObject:options:error:] + 332
15 meyumeapp 0x001bcbb8 +[CBLJSON dataWithJSONObject:options:error:] (CBLJSON.m:43)
16 meyumeapp 0x00185f94 -[CBL_Body asJSON] (CBL_Body.m:72)
17 meyumeapp 0x00226892 -[CBL_Router sendResponseBodyAndFinish:] (CBL_Router.m:536)
18 meyumeapp 0x00225804 -[CBL_Router run] (CBL_Router.m:415)
19 meyumeapp 0x00226f1c __19-[CBL_Router start]_block_invoke_0 (CBL_Router.m:583)
20 meyumeapp 0x0018a7ce __34-[CBL_Server tellDatabaseManager:]_block_invoke_0 (CBL_Server.m:154)
21 meyumeapp 0x001e552c -[NSObject(MYBlockUtils) my_run_as_block] (MYBlockUtils.m:22)
22 Foundation 0x38bc58e8 __NSThreadPerformPerform + 456
23 CoreFoundation 0x3254667e __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 10
24 CoreFoundation 0x32545ee4 __CFRunLoopDoSources0 + 208
25 CoreFoundation 0x32544cb2 __CFRunLoopRun + 642
26 CoreFoundation 0x324b7eb8 CFRunLoopRunSpecific + 352
27 CoreFoundation 0x324b7d44 CFRunLoopRunInMode + 100
28 Foundation 0x38b1878a -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 250
29 meyumeapp 0x0018a420 -[CBL_Server runServerThread] (CBL_Server.m:130)
30 Foundation 0x38bc5678 __NSThread__main__ + 968
31 libsystem_c.dylib 0x391d430c _pthread_start + 304
32 libsystem_c.dylib 0x391d41d4 thread_start + 4
Hi, I removed the credentials from both the server and client sides of the test, I now get an exception thrown on the device acting as the server and the App crashes.
Jens
On Feb 4, 2015, at 11:56 PM, Alex Lai <alex...@gmail.com> wrote:Hi, buddy. Do you still work on CBL P2P replication? P2P replication really caught me sight and I am working on this. May I have your this program's source code? Thank you.
On Jun 11, 2015, at 9:43 AM, Yonah Forst <yonah...@gmail.com> wrote:Were you ever able to re-enable credentials? I'm getting the exact same error (1005 on the client side and 404 on the CBLListener side). It works great when I disable the credentials...
On Jun 11, 2015, at 12:09 PM, Brendan Duddridge <bren...@gmail.com> wrote:Noticed the P2P PhotoDrop example doesn't compile for iOS 9 or Xcode 7. An objective-c example would be helpful too. I've dabbled in Swift, but not really fluent in it yet.
CBLRemoteJSONRequest[GET https://iPhone-6-Plus.local:54734/db/_local/0253a83e5ef3796a22adea200a869db0106a2f5a]: Got error Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo=0x14ced6370 {NSUnderlyingError=0x14ced44b0 "The request timed out.", NSErrorFailingURLStringKey=https://iphone-6-plus.local:54734/db/_local/0253a83e5ef3796a22adea200a869db0106a2f5a, NSErrorFailingURLKey=https://iphone-6-plus.local:54734/db/_local/0253a83e5ef3796a22adea200a869db0106a2f5a, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out.}
2015-06-11 17:19:13.093 PhotoDrop[525:322749] HTTPServer: Started HTTP server on port 54734
self.listener = [[CBLListener alloc] initWithManager:[CBLManager sharedInstance] port:52021];
self.listener.requiresAuth = YES;
[self.listener setPasswords:@{[self authenticatorUsername] : [self authenticatorPassword]}];
[self.listener setBonjourName:[self myUUID] type: [self bonjourType]];
[self.listener start:&error]
NSURL *serviceURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://%@:%li", service.hostName, service.port]];
NSURL *databaseURL = [NSURL URLWithString:[[self database] name] relativeToURL:serviceURL];
NSURLComponents *components = [NSURLComponents componentsWithURL:databaseURL resolvingAgainstBaseURL:YES];
components.user = [self authenticatorUsername];
components.password = [self authenticatorPassword];
self.pullReplication = [[self database] createPullReplication:components.URL];
self.pullReplication.continuous = self.isContinuous;
self.pullReplication.customProperties = @{@"websocket": @NO};
self.pullReplication.filter = @"exceptUUIDAndMinUpdatedAt";
self.pullReplication.filterParams = @{@"exceptUUID": uuid, @"minUpdatedAt": [CBLJSON JSONObjectWithDate:minUpdatedAt]};
[self.pullReplication start];
CBLListener: Login attempted for user 'p2p_v1'
CBLListener: GET /proximator/_local/e95ce455ab12e1261e4f6b592ee4cc8f478c8eaa
CBLListener: Response[GET /proximator/_local/e95ce455ab12e1261e4f6b592ee4cc8f478c8eaa] --> 404