简体   繁体   English

WSO2 APi管理器响应代码0

[英]WSO2 APi Manager Response Code 0

I'm trying to use WSO2 API Manager 1.10.0 on an existent micro-services project with REST APIs following WSO2 tutorial. 我正在尝试按照WSO2教程在具有REST API的现有微服务项目上使用WSO2 API Manager 1.10.0。

I have installed it on my computer as well as a copy of my application and configured AM to manage requests (GET, POST and DELETE) to my resource but I always obtain a "Response code 0" with Response Header 我已经在计算机上安装了它以及应用程序的副本,并配置了AM来管理对我的资源的请求(GET,POST和DELETE),但是我总是通过Response Header获得“ Response code 0”

{
   "error": "no response from server"
}

Trying to contact my application using Advanced REST Client I obtain 200 with the correct result. 尝试使用Advanced REST Client与我的应用程序联系时,我得到200正确的结果。

My APIs use a token inside the header to authenticate the user passed so I have implemented a dummy API without authentication but I still have the same issue. 我的API使用标头中的令牌来验证通过的用户,因此我实现了未经身份验证的虚拟API,但仍然存在相同的问题。

I have tried also the Cloud version with our test server but still obtaining the same result. 我也在我们的测试服务器上尝试了Cloud版本,但仍然获得了相同的结果。 I found this guide http://wso2.com/blogs/cloud/video-setting-up-custom-url-for-api-store-and-gateway/ but I don't know if this can be a solution for the problem in localhost. 我在http://wso2.com/blogs/cloud/video-setting-up-custom-url-for-api-store-and-gateway/中找到了该指南,但我不知道这是否可以解决本地主机的问题。

Setting up the custom url in WSO2 API Cloud wont help. WSO2 API Cloud中设置自定义网址将无济于事。 Thats there for a different purpose. 那是出于不同的目的。 There are two things you can do. 您可以做两件事。

  1. If you are interested in going ahead with the cloud version, you can get help from them. 如果您有兴趣继续使用云版本,可以从他们那里获得帮助。 You can send a support request and the cloud team will help. 您可以发送支持请求,云团队将为您提供帮助。

  2. You can troubleshoot your local instance. 您可以对本地实例进行故障排除。 When doing so, first, try to invoke your api via curl and see whether it gets a response. 这样做时,首先,尝试通过curl调用您的api,看看它是否得到响应。 Sometime, your api can work fine, but due to some reasons, the result might not reach the api console. 有时,您的api可以正常工作,但是由于某些原因,结果可能无法到达api控制台。

If the curl works fine or not, you can check the logs to see whether there are any errors printed. 如果卷曲是否正常,则可以检查日志以查看是否打印了任何错误。 Some more questions: 还有一些问题:

  1. Is your backend service exposed via http or https? 您的后端服务是否通过http或https公开?
  2. If it is https, then if its certificate is not a CA signed one, API Manager will fail during the handshake. 如果是https,则如果其证书不是经过CA签名的证书,则API Manager在握手期间将失败。 If so, you will have to add the cert to api managers client-truststore.jks 如果是这样,则必须将证书添加到api管理器client-truststore.jks
  3. In the cloud scenario, your backend should be accessible from internet and the certificate story is valid for cloud too. 在云方案中,您的后端应该可以从Internet访问,并且证书故事也适用于云。

Are you trying to access the api using swagger console (or any web application). 您是否要使用swagger控制台(或任何Web应用程序)访问api。 There are couple of reasons you could encounter this issue. 您可能会遇到此问题的原因有两个。 one could be certificate not installed in the browser. 一种可能是浏览器中未安装证书。

If this happens you should see some error log in the api manager console (something related to CA not found). 如果发生这种情况,您应该在api管理器控制台中看到一些错误日志(找不到与CA相关的内容)。 for that first you can copy the backend url (swagger console shows the url it used to send the request) and paste it on a new browser window and install the certificate to the browser. 为此,您可以复制后端url(swagger控制台显示用于发送请求的url)并将其粘贴到新的浏览器窗口中,然后将证书安装到浏览器。

also you can get an idea about the issue by using a tool like firebug and check the request. 您也可以使用Firebug之类的工具来了解该问题,然后检查请求。 (it will show the error for not connecting the AM) (它将显示未连接AM的错误)

Finally I have found the issue: the API Manager does not accept plain text response, responding using a JSON solves the problem. 最后,我发现了问题:API管理器不接受纯文本响应,使用JSON响应可以解决问题。

Using other mediatype such as XML or TEXT/HTML it reports 406, with text plain it returns Error 0. 使用其他媒体类型(例如XML或TEXT / HTML),它会报告406,以纯文本格式会返回错误0。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM