I am trying to configure MF container to use Cloudant. And query clouding from the mobile app through the data proxy.
I followed the instructions in to configure the data proxy on the container: http://www-01.ibm.com/support/knowledgecenter/?lang=en#!/SSHS8R_7.1.0/com.ibm.worklight.deploy.doc/deploy/t_configure_data_proxy.html
I configured the file /ibm-mfpf-container-7.1.0.0-eval/mfpf-server/usr/env/server.env to have the following value:
publicKeyServerUrl=HTTP_CONTAINER_PUBLIC_IP_PORT/MF_PROJECT_CONTEXT_ROOTAnd the file /ibm-mfpf-container-7.1.0.0-eval/mfpf-server/usr/config/dataproxy.xml to have the following value:
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed Materials - Property of IBM 5725-I43 (C) Copyright IBM Corp. 2015, 2015. All Rights Reserved. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. --> <server description="new server"> <!-- Enable features --> <featureManager> <!-- Data proxy features --> <feature>jaxrs-1.1</feature> <feature>jndi-1.0</feature> <feature>usr:OAuthTai-1.0</feature> <!-- --> </featureManager> <!-- OAuth TAI For Data Proxy --> <!--OAuth TAI For Data Proxy. --> <usr_OAuthTAI cacheSize="1000" id="myOAuthTAI"> <securityConstraint httpMethods="All" securedURLs="datastore" scope="cloudant"/> </usr_OAuthTAI> <!-- --> <!-- --> <webApplication contextRoot="datastore" id="imf-data-proxy" location="imf-data-proxy.war" name="imf-data-proxy"> <application-bnd> <security-role name="TAIUserRole"> <special-subject type="ALL_AUTHENTICATED_USERS" /> </security-role> </application-bnd> <classloader delegation="parentLast"> <commonLibrary> <fileset dir="${wlp.install.dir}/lib" includes="com.ibm.ws.crypto.passwordutil*.jar"/> </commonLibrary> </classloader> </webApplication> <!-- --> <!-- Declare the JNDI properties for the MobileFirst Data Proxy. Note: These jndi properties are not required if a bluemix app is bound to the container when startserver.sh or startservegroup.sh is executed. Also, uncomment the entry publicKeyServerUrl in server.env and fill in the correct URL. <jndiEntry jndiName="datastore/CloudantProxyDbAccount" value='"hostname"'/> <jndiEntry jndiName="datastore/CloudantProtocol" value='"http"'/> <jndiEntry jndiName="datastore/CloudantPort" value='"80"'/> <jndiEntry jndiName="datastore/CloudantProxyDbAccountUser" value='"cloudantuser"'/> <jndiEntry jndiName="datastore/CloudantProxyDbAccountPassword" value='"cloudantpassword"'/> --> </server>Then I ran the scripts prepareserver and start server.
When I open
http://CONTAINER_PUBLIC_IP:9080/datastoreI get the following response, which seems fine: {"imfdata":"ok","version":"1.0"}I ran the bluelist sample on this container and I am not able to get it running. It throws the following exception:
2015-10-08 00:05:34.055 bluelist-objective-c[37850:708865] *** Terminating app due to uncaught exception 'Fatal Exception from Proxy', reason: 'Could not create remote database todosdb. Error: Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSUnderlyingError=0x7fcf72e6efa0 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "The request timed out." UserInfo={NSErrorFailingURLStringKey=IP_PF_CONTAINER:9080/datastore/api/v1/apps/default/todosdb, NSErrorFailingURLKey= IP_PF_CONTAINER:9080/datastore/api/v1/apps/default/todosdb, _kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4, NSLocalizedDescription=The request timed out.}}, NSErrorFailingURLStringKey=HTTP_CONTAINER_PUBLIC_IP_PORT/datastore/api/v1/apps/default/todosdb, NSErrorFailingURLKey=http://134.168.13.219:9080/datastore/api/v1/apps/default/todosdb, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out.}'
This is thrown from the iPhone simultator running this code:
[manager remoteStore:dbname completionHandler:^(CDTStore *store, NSError *error) {...I have set cloudantProxyURL in the Objective C code to the following:
CONTAINER_PUBLIC_IP:9080/MF_PROJECT_CONTEXT_ROOT
Any idea where the problem is? I wan to troubleshoot without security. Can I make unauthenticated calls to Cloudant through the IMFDataManager API and data proxy? Or user has to be authenticated?
===============
I could enforce authentication by calling an adapter before calling [manager remoteStore], and authentication is successful. I still get an error when I run the following code to connect to a DB on Cloudant and query from it. [manager remoteStore] is the one that throws the error:
IMFDataManager *manager = [IMFDataManager initializeWithUrl:@"HTTP_HOST_PORT/datastore"];
// Get reference to data manager
//manager = [IMFDataManager sharedInstance];
NSString *dbname = @"orders_db";
// Create remote store
[manager remoteStore:dbname completionHandler:^(CDTStore *store, NSError *error) {
if(error){
// Handle error
NSLog(@"Error: %@ %@", error, [error userInfo]);
}else{
CDTStore *remotedatastore = store;
NSLog(@"Successfully created store");
}
}];
I am getting this error:
2015-10-09 02:14:39.029 bluelist-objective-c[2655:52223] Error: Error Domain=NSURLErrorDomain Code=-1012 "(null)" UserInfo={NSErrorFailingURLStringKey=http://134.168.13.219:9080/datastore/api/v1/apps/default/orders_db, NSUnderlyingError=0x7fa270c27270 {Error Domain=kCFErrorDomainCFNetwork Code=-1012 "(null)" UserInfo={_kCFURLErrorAuthFailedResponseKey={url = http://134.168.13.219:9080/datastore/api/v1/apps/default/orders_db}}}, NSErrorFailingURLKey=http://134.168.13.219:9080/datastore/api/v1/apps/default/orders_db} { NSErrorFailingURLKey = "http://134.168.13.219:9080/datastore/api/v1/apps/default/orders_db"; NSErrorFailingURLStringKey = "http://134.168.13.219:9080/datastore/api/v1/apps/default/orders_db"; NSUnderlyingError = "Error Domain=kCFErrorDomainCFNetwork Code=-1012 \"(null)\" UserInfo={_kCFURLErrorAuthFailedResponseKey={url = http://134.168.13.219:9080/datastore/api/v1/apps/default/orders_db}}"; }
=====
Another point, when I login to the container using SSH and display the server.xml in /opt/ibm/wlp/usr/servers/worklight/server.xml I don't find the lines for OAuth TAI added. There are not there at all.