0

I'm trying to use WSO2 API Manager 1.10.0 on an existent micro-services project with REST APIs following WSO2 tutorial.

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

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

Trying to contact my application using Advanced REST Client I obtain 200 with the correct result.

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.

I have tried also the Cloud version with our test server but still obtaining the same result. 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.

Amila Maharachchi
  • 2,121
  • 2
  • 15
  • 21

3 Answers3

1

Setting up the custom url in WSO2 API Cloud wont help. 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. Sometime, your api can work fine, but due to some reasons, the result might not reach the api console.

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?
  2. If it is https, then if its certificate is not a CA signed one, API Manager will fail during the handshake. If so, you will have to add the cert to api managers client-truststore.jks
  3. In the cloud scenario, your backend should be accessible from internet and the certificate story is valid for cloud too.
Amila Maharachchi
  • 2,121
  • 2
  • 15
  • 21
  • Thank you for the answer, I have tried the cloud version just to exclude a relation between this issue and my installation. I have inserted debug in the dump API and it receives the correct request but still I have no response on the client, curl reports "(60) SSL certificate problem: unable to get local issuer certificate". I use http on the localhost and both http and https on the server, but the certificate for API Manager is invalid, I have tried to export it an import as self certificate but chrome still report an unsafe connection. – Alessandro Valentini Jul 22 '16 at 07:47
  • If you try curl in WSO2 API Cloud, it will not complain about the certificate. In your local deployment, it complains because the certificate is not a CA signed one. You can get rid of that by invoking the curl with -k option. What was your result in the cloud version for curl? – Amila Maharachchi Jul 24 '16 at 12:33
  • Now I am able to reach my resources through a rest client but I'm still not able to test them using the web interface of API Manager because of the "Return state 0" error. I don't intend to use the cloud version because the API manager has to be installed on our server however the problem persists even with it. – Alessandro Valentini Jul 26 '16 at 06:36
1

Are you trying to access the api using swagger console (or any web application). 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). 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.

also you can get an idea about the issue by using a tool like firebug and check the request. (it will show the error for not connecting the AM)

Chamila Adhikarinayake
  • 3,588
  • 5
  • 25
  • 32
  • thank you, probably my issue is related to the invalid certificate, I tried to save the missing certificate in chrome (clic on the red lock -> details -> view certificate -> save to file) and import it as "trusted root certificate", however the url still result unsafe. How can I get rid of that? Does it make any difference if I download the certificate from https://192.168.123.45:9443/.../ (by default WSO2 uses machine's IP) instead of https://localhost:9443/.../? I have tried both – Alessandro Valentini Jul 22 '16 at 07:59
  • Importing the certificate downloaded from chrome both as Intermediate Certification Authority and Trusted Root Certification Authority, setting up header parameter "Authorization" with the proper key (in addition to my token) and enabling XHR in Advanced Rest Client I am able to obtain the correct response through the https URL provided by the API Manager, but I am still getting "no response from server" using the WSO2 web interface, and the page is still reported as unsafe. – Alessandro Valentini Jul 22 '16 at 09:29
  • WSO2 products comes with self signed certificates. that's why it shows the url is unsafe. You can add CA signed certificate to the product. see http://wso2.com/library/knowledge-base/2011/08/adding-ca-certificate-authority-signed-certificate-wso2-products/ – Chamila Adhikarinayake Jul 23 '16 at 02:56
1

Finally I have found the issue: the API Manager does not accept plain text response, responding using a JSON solves the problem.

Using other mediatype such as XML or TEXT/HTML it reports 406, with text plain it returns Error 0.