【问题标题】:Unable to Configure Cloudant Data Proxy on MobileFirst container on Bluemix无法在 Bluemix 上的 MobileFirst 容器上配置 Cloudant 数据代理
【发布时间】:2015-10-07 23:07:41
【问题描述】:

我正在尝试将 MF 容器配置为使用 Cloudant。并通过数据代理从移动应用查询云。

  • 我按照中的说明在容器上配置数据代理: http://www-01.ibm.com/support/knowledgecenter/?lang=en#!/SSHS8R_7.1.0/com.ibm.worklight.deploy.doc/deploy/t_configure_data_proxy.html

  • 我将文件 /ibm-mfpf-container-7.1.0.0-eval/mfpf-server/usr/env/server.env 配置为具有以下值:

    publicKeyServerUrl=HTTP_CONTAINER_PUBLIC_IP_PORT/MF_PROJECT_CONTEXT_ROOT
    
  • 并且文件 /ibm-mfpf-container-7.1.0.0-eval/mfpf-server/usr/config/dataproxy.xml 具有以下值:

    <?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>
    
  • 然后我运行脚本 prepareserver 并启动服务器。

  • 当我打开 http://CONTAINER_PUBLIC_IP:9080/datastore 时,我得到以下响应,这似乎很好: {"imfdata":"ok","version":"1.0"}

  • 我在此容器上运行了 bluelist 示例,但无法使其运行。它抛出以下异常:

2015-10-08 00:05:34.055 bluelist-objective-c[37850:708865] *** 由于未捕获的异常“来自代理的致命异常”而终止应用程序,原因:“无法创建远程数据库 todosdb。错误:错误域=NSURLErrorDomain 代码=-1001“请求超时。” UserInfo={NSUnderlyingError=0x7fcf72e6efa0 {错误域=kCFErrorDomainCFNetwork Code=-1001“请求超时。” 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=请求超时。}}, 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=请求超时。}' p>

  • 这是从运行此代码的 iPhone 模拟器抛出的:

    [manager remoteStore:dbname completionHandler:^(CDTStore *store, NSError *error) {...
    
  • 我已将 Objective C 代码中的 cloudantProxyURL 设置为以下内容:

    CONTAINER_PUBLIC_IP:9080/MF_PROJECT_CONTEXT_ROOT
    

知道问题出在哪里吗?我想在没有安全性的情况下进行故障排除。我可以通过 IMFDataManager API 和数据代理对 Cloudant 进行未经身份验证的调用吗?还是必须对用户进行身份验证?

================

我可以通过在调用 [manager remoteStore] 之前调用适配器来强制执行身份验证,并且身份验证成功。我仍然收到错误消息 当我运行以下代码连接到 Cloudant 上的数据库并从中查询时。 [manager remoteStore] 是抛出错误的那个:

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");
    }
}];

我收到此错误:

2015-10-09 02:14:39.029 bluelist-objective-c[2655:52223] 错误:错误域=NSURLErrorDomain 代码=-1012“(null)”UserInfo={NSErrorFailingURLStringKey=http://134.168.13.219:9080/datastore/api/v1/apps/default/orders_db,NSUnderlyingError=0x7fa270c27270 {错误域=kCFErrorDomainCFNetwork 代码=-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 = "错误域=kCFErrorDomainCFNetwork 代码=-1012 \"(null)\" UserInfo={_kCFURLErrorAuthFailedResponseKey={url = http://134.168.13.219:9080/datastore/api/v1/apps/default/orders_db}}"; }

=====

另一点,当我使用 SSH 登录容器并在 /opt/ibm/wlp/usr/servers/worklight/server.xml 中显示 server.xml 时,我没有找到添加 OAuth TAI 的行。根本没有。

【问题讨论】:

  • 我有几个问题。 -您使用哪种身份验证? (从 Cloudant 创建后端数据库需要进行身份验证)-我假设您使用的是 Bluelist。您使用的是什么版本的应用程序?你是从哪里下载的?我还注意到您在上面清除了您的 IP,但似乎您在最后一条错误消息中错过了一个。
  • 我使用最新版本hub.jazz.net/project/mobilecloud/mfp-bluelist-on-premises/… 身份验证是基于适配器的身份验证,用于验证小说名称(詹姆斯,42 岁)。感谢您的提示,由于此验证,我在发布之前清理了 IP,以使 URL 少于两个。
  • 你应该在这里尝试托管在 github 上的最新版本:教程:developer.ibm.com/mobilefirstplatform/documentation/… 示例:github.com/MobileFirst-Platform-Developer-Center/…
  • @Jaalger 我不认为这是问题所在。我现在可以进行身份​​验证,但相同的代码失败了。创建我上面提到的远程商店的那个。
  • 我已经编辑了这个问题。我想知道活跃在这里的 IBM Bluemix 支持人员在哪里!!!!!!这很重要,容器根本不起作用!

标签: ibm-cloud ibm-mobilefirst cloudant


【解决方案1】:

上述异常表示授权访问数据代理组件不成功。

您能否修改 dataproxy.xml 以提供正确的securedUrls 参数。 secureURLs 的值应该是“/datastore/*”而不是“datastore”。更新的 sn-p 在这里:

<usr_OAuthTAI cacheSize="1000" id="myOAuthTAI">
    <securityConstraint httpMethods="All" securedURLs="/datastore/*" scope="cloudant"/>
</usr_OAuthTAI>

如果 dataproxy 使用它可以正常工作,请告诉我。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多