简体   繁体   English

在本地主机上测试App Engine端点(IOS和Python)

[英]testing app engine endpoints at localhost (IOS & Python)

My endpoints work via API-Explorer, and also work in the app-engine runtime environment (over the net) 我的端点通过API-Explorer工作,也可以在App Engine运行时环境中(通过网络)工作

But when I point my IOS client (via the simulator) to localhost:8080, my IOS tests fail and I'm seeing empty message payloads arriving at the endpoint (on the python side) 但是,当我将IOS客户端(通过模拟器)指向localhost:8080时,我的IOS测试失败,并且我看到空消息有效负载到达端点(在python端)

It's quite frustrating and I've been trying to figure it out for several days..... 这真令人沮丧,我已经尝试了好几天。

I went into the protorpc source and added a print and get this: 我进入了protorpc来源,并添加了打印件并得到了这个:

{
  "jsonrpc": "2.0",
  "method": "tstone.person.createGuy",
  "id": "gtl_1",
  "params": {
    "resource": {
      "isFemale": false,
      "alias": "Alias",
      "city": "Hanoi",
      "id": "1",
      "mobile": "+84932340799",
      "privs": "privs",
      "email": "hodanhcXXXgmail.com",
      "last": "Danh Chuan",
      "first": "Ho",
      "tags": "tags"
    }
  },
  "apiVersion": "v1"
}

So it's clear my data is arriving from the IOS client, but somewhere in the mix it's getting lost so that there is no data on the properties of the "request" message that reaches my code...... all == None I also see this warning in the server console: 所以很明显我的数据是从IOS客户端到达的,但是在混合中的某个地方它丢失了,因此在到达我的代码的“请求”消息的属性上没有数据…… all == None还可以在服务器控制台中看到此警告:

protojson.py:267] No variant found for unrecognized field: resource

Stack overflow implies that "variant " error was common (on localhost) in a version of the dev server over 1.5 years ago......and I'm on (the latest) version: 堆栈溢出表示“可​​变”错误在1.5年前的开发服务器版本中很常见(在localhost上)……而我正在使用(最新)版本:

  • app-engine-python 1.9.34 app-engine-python 1.9.34
  • core 2016.03.22 核心2016.03.22

Since it works in the above (API-Explorer/app-engine runtime) environments, I surmise that it's not a problem with my code and instead an issue with my install or local config 由于它可以在上述(API-Explorer / app-engine运行时)环境中运行,因此我推测这不是我的代码问题,而是我的安装或本地配置问题

So I started looking through the modules in my vendored /lib directory to see if any were old versions or conflicting with something in the dev_appserver modules.... 因此,我开始浏览供应商提供的/ lib目录中的模块,以查看是否有旧版本或与dev_appserver模块中的内容冲突。...

I found several that I suspect should NOT be there..... It seems like app engine should already have many of these in it's own path: 我发现有几个我怀疑应该不存在的地方.....看来,应用程序引擎应该已经在自己的路径中包含了许多:

  • apiclient api客户端
  • googleapiclient googleapiclient
  • httplib2 httplib2
  • oauth2 oauth2
  • oauth2client (used by identity toolkit so this one is probably ok) oauth2client(由身份工具包使用,因此这一点可能还可以)
  • protopigeon (a dep of ferris3 so I guess this is ok too) protopigeon(ferris3的一个部门,所以我想也可以)
  • pyasn1 pyasn1
  • pyasn1_modules pyasn1_modules
  • rsa rsa
  • simpleauth (I'm also using this for identity toolkit so its ok) simpleauth(我也将其用于身份工具包,所以还可以)
  • simplejson simplejson
  • six
  • wsgiproxy wsgiproxy

Furthermore, on the Ferris install page, I found this: 此外,在Ferris安装页面上,我发现了这一点:

If you're starting from scratch and you're using webapp2 or just using Cloud Endpoints: use the Skeleton project 如果您是从头开始,并且正在使用webapp2或仅使用Cloud Endpoints,请使用Skeleton项目

So if we are NOT using webapp2, we're allowed to do a simple pip install ferris , but if we ARE using endpoints or webapp2, we must go through some complex process via Node, Yeoman, and Ferris generator..... 因此,如果我们不使用webapp2,则可以进行简单的pip install ferris ,但是如果我们使用端点或webapp2,则必须通过Node,Yeoman和Ferris生成器进行一些复杂的过程。

Why the added complexity.....can someone please explain this to me? 为什么增加的复杂性.....有人可以向我解释一下吗?

And thanks for any tips!! 并感谢您的提示!! Dewey 杜威

  1. Regarding the Ferris 3 project, there's the option to use the ferris 3 generator to help you with a simple predefined app showing a simplified structure of how to get started with the project. 关于Ferris 3项目,可以选择使用ferris 3生成器来帮助您使用一个简单的预定义应用程序,该应用程序显示了如何开始该项目的简化结构。 Since it's a yeoman generator, you'll need nodejs , yeoman, etc... 由于它是yeoman生成器,因此您需要nodejs ,yeoman等。

    But all of that is optional . 但是所有这些都是可选的 Nothing complex. 没什么复杂的。 They're just there as an option to jump start into bigger stuff, handling a bit of boilerplate :) 他们只是一个选择,可以跳入更大的领域,处理一些样板:)

  2. Ferris depends on the google-api-python-client which in turn needs all those dependencies. Ferris依赖于google-api-python-client ,而后者又需要所有这些依赖项。

    True, these dependencies seem to come as part of the app engine & google cloud sdk's lib & third party lib folders respectively so I guess they can be added in the app.yaml 's libraries section. 的确,这些依赖关系似乎分别作为应用程序引擎和Google Cloud SDK的lib和第三方lib文件夹的一部分出现,因此我想可以将它们添加到app.yaml “库”部分中。 But it's difficult tracking down versions from there, and from prior experience I can say with some degree of certainty that you wouldn't want to depend on those in production. 但是从那里跟踪版本很困难,并且根据以前的经验,我可以肯定地说,您不想依赖生产版本。 They're not pinned and thus change all the time. 它们没有固定,因此一直在变化。 For a list of absolutely supported libs you can check out https://cloud.google.com/appengine/docs/python/tools/libraries27 有关绝对受支持的库的列表,可以查看https://cloud.google.com/appengine/docs/python/tools/libraries27

    I've always vendored the google-api-python-client as advised @ https://developers.google.com/api-client-library/python/start/installation#appengine So what you have now is correct. 我一直按照@ https://developers.google.com/api-client-library/python/start/installation#appengine的建议出售google-api-python-client,所以您现在所拥有的是正确的。

  3. Last but not least, like you rightly point out, the error you're seeing seems to have existed for quite some time. 最后但并非最不重要的一点,正如您正确指出的那样,您看到的错误似乎已经存在了一段时间。 Dave Fisher provides a workaround for the unrecognized field: 'resource' error in his answer from a few years back which has proved helpful. Dave Fisher为unrecognized field: 'resource'提供了一种解决方法unrecognized field: 'resource' 几年前他的回答中出现unrecognized field: 'resource'错误,事实证明是有帮助的。

BTW this issue is fixed on the latest version of the Google API Objective-C client library. 顺便说一句,此问题已在最新版本的Google API Objective-C客户端库中修复。 Time to port everything to GTLR. 是时候将所有内容移植到GTLR了。 Yeah! 是的 :) :)

https://github.com/google/google-api-objectivec-client-for-rest https://github.com/google/google-api-objectivec-client-for-rest

Other docs for GTLR stuff: https://github.com/google/google-api-objectivec-client-for-rest/wiki http://cocoadocs.org/docsets/GoogleAPIClientForREST 有关GTLR内容的其他文档: https : //github.com/google/google-api-objectivec-client-for-rest/wiki http://cocoadocs.org/docsets/GoogleAPIClientForREST

Warning we hit a bug using that library were we had to replace some of the library generated #import lines. 警告我们使用该库遇到错误,因为我们必须替换一些由库生成的#import行。 I forget the details, but it was an easy edit. 我忘记了细节,但这很容易编辑。 I just hate modifying generated code. 我只是讨厌修改生成的代码。

The real pain is all the other little changes to do the port. 真正的痛苦是要做端口的所有其他小变化。 ;) It is a better system and a good port to do though. ;)这是一个更好的系统,也是一个不错的端口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 iOS App Engine端点分页 - ios app engine endpoints paging 端点可在localhost上运行,但不能在应用程序引擎上运行(省略https://) - Endpoints work on localhost but not on app engine (omitted https://) Google App Engine端点api在localhost中不起作用 - Google app engine endpoints api not working in localhost 使用App Engine SDK在localhost中部署我的Google端点python应用程序时出错 - Error when I am deploying my google cloud endpoints python application in localhost with App Engine SDK 迁移至Cloud Endpoints 2.0-在localhost上工作,但在App Engine上工作 - Migrating to Cloud Endpoints 2.0 - Working on localhost but not on App Engine 使用适用于Google App Engine的Cloud Endpoints对Android App进行本地测试 - Local testing for Android App using Cloud Endpoints for Google App Engine Google App Engine Python身份验证端点和Android - Google App Engine Python Authenticated Endpoints and Android 带有 Android 的 Google App Engine - 在真实设备上测试端点 - Google App Engine with Android - testing endpoints on real device App Engine云端点单元测试,数据核问题,可能吗? - App Engine Cloud Endpoints Unit Testing, Issues with Data Nucleus, Is it possible? 如何在IOS中为Google App Engine端点启用可选参数 - How to enable optional parameters in IOS for Google App Engine endpoints
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM