Weird issue fetching HTTP URL on Production AppEngine instance [Java] - google-app-engine

I am quite puzzled by this behavior.
I have a Java AppEngine instance which makes an http call to a "settings.php" on another server. But I get the following error:
ERROR :
java.io.IOException: Could not fetch URL: http://<3rdpartywebsite>/settings.php
at com.google.appengine.api.urlfetch.URLFetchServiceImpl.convertApplicationException(URLFetchServiceImpl.java:138)
at com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:45)
at com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:30)
...
I have tried using URLFetchService and even a simple HttpURLConnection class. Even tried with a different User-Agent and other http headers, but to no avail.
What is baffling is that the same code and website works fine on Local Eclipse Dev environment, works via Browser (can see php text) AND works on the Compute Engine too! Only the Production App Engine throws the "could not fetch" error. Unfortunately this is not a transient error, it fails 10/10 times.
Any idea what could be going wrong or something that I can try?
Thanks, Asim

Related

Camel recipientList and get the error of HTTP operation failed invoking Url with statusCode: 404

I have setup a local mock service in SoapUI. If I call it by postman and it works. If I calls it by my new endpoint in an existing project which using recipientList, it will get "HTTP operation failed invoking Url with statusCode: 404" (sometimes get 500).
<recipientList>
<simple>{{localhost url}}</simple>
</recipientList>
This project exists for few years and it is stable. I have developed this endpoint and tested it before. When I merge it to the new branch it fails. I am not sure whether I changed something which unnoticed. Actually it is not just endpoint, but all the endpoint when using recipientList will throw the above error. I have tried JBoss and Tomcat 9, both of them have same error. It is weird that if I call from postman or chrome, then it works.
I am thinking that maybe there are some setting about my computer. Initial I though it maybe wrong from the new branch of that project. I revert it back to version which it has been tested, and it still throw this 404 error.

requests are working locally but not on Heroku. Getting internal server error 500 and JSON not valid

I built a web application with django and react. It is working perfectly fine locally and the heroku deployment worked fine without issues.
When I am testing the heroku app some of my requests are working fine like login/register. However the request where information is being sent back from the server to be displayed or post requests sending information are giving me the following error
GET [request name] 500 (Internal Server Error)
and
Uncaught (in promise) SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
Would this issue be related to my requirements.txt or Procfile? Since the issue is not happening when the project is run locally and only on heroku.
Could anyone point me in the right direction?

Google App Engine Deployment fais with Intellij idea

I am developing a Google App Engine application with IntelliJ idea, the app is running successfully on local machine but when I need to deploy it on my cloud it fails and I get the following error :
Password for myemail#gmail.com:
java.lang.RuntimeException: Bad authentication response: 404 Not Found
Unable to update app: Bad authentication response: 404 Not Found
please see the log
Having checked the log file the content was:
java.lang.RuntimeException: Bad authentication response: 404 Not Found
at com.google.appengine.tools.admin.ClientLoginServerConnection.getAuthToken(ClientLoginServerConnection.java:250)
at com.google.appengine.tools.admin.ClientLoginServerConnection.authenticate(ClientLoginServerConnection.java:86)
at com.google.appengine.tools.admin.ClientLoginServerConnection.doHandleSendErrors(ClientLoginServerConnection.java:120)
at com.google.appengine.tools.admin.AbstractServerConnection.send1(AbstractServerConnection.java:296)
at com.google.appengine.tools.admin.AbstractServerConnection.send(AbstractServerConnection.java:253)
at com.google.appengine.tools.admin.AbstractServerConnection.post(AbstractServerConnection.java:232)
at com.google.appengine.tools.admin.LoggingClientDeploySender.send(LoggingClientDeploySender.java:47)
at com.google.appengine.tools.admin.ResourceLimits.remoteRequest(ResourceLimits.java:173)
at com.google.appengine.tools.admin.ResourceLimits.request(ResourceLimits.java:139)
at com.google.appengine.tools.admin.AppAdminImpl.doUpdate(AppAdminImpl.java:467)
at com.google.appengine.tools.admin.AppAdminImpl.update(AppAdminImpl.java:55)
at com.google.appengine.tools.admin.AppCfg$UpdateAction.execute(AppCfg.java:1347)
at com.google.appengine.tools.admin.AppCfg.executeAction(AppCfg.java:332)
at com.google.appengine.tools.admin.AppCfg.<init>(AppCfg.java:213)
at com.google.appengine.tools.admin.AppCfg.<init>(AppCfg.java:124)
at com.google.appengine.tools.admin.AppCfg.main(AppCfg.java:120)
Caused by: java.io.FileNotFoundException: https://www.google.com/accounts/ClientLogin
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1834)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at com.google.appengine.tools.admin.AbstractServerConnection.connect(AbstractServerConnection.java:133)
at
I also have searched for this error and I think this link should address this issue
Issue 12898: Some AppEngine deploys are failing
I uploaded a picture from the setting up App Engine deployment,
Question : What exactly should I change in order to get it working and successfully deploying on the App Engine Server?
I solved the issue by appcfg.cmd [options] update <war-location> and adding the argument --oauth2 to the command it should have been also solved by updating the sdk versionas mentioned in comments

Invalid json error when trying to post to web server using CN1 javascript port

I get an error 400 from parse.com when trying to post data using the javascript CodenameOne port. The same code works fine in the simulator and mobile app versions.
I followed the Chrome debugging steps mentioned here and it's pretty hard to see what's happening. I see though that the parse4cn1 logging is identical to that on the simulator except that the latter succeeds whereas the javascript call fails:
Log from javascript port:
[parse4cn1] Data to be sent: {"data":{"timestamp":1457471857989,"mood":2,"user":"WQpcT5uzxM"}}
[parse4cn1] Request URL: https://api.parse.com/1/classes/Mood
[parse4cn1] Raw response (as string): {"code":107,"error":"invalid JSON"}
Log from simulator:
[invokeAndBlock2] 0:0:18,928 - [parse4cn1] Data to be sent: {"data":{"mood":2,"user":"WQpcT5uzxM","timestamp":1457472171236}}
[invokeAndBlock2] 0:0:18,928 - [parse4cn1] Request URL: https://api.parse.com/1/classes/Mood
[invokeAndBlock2] 0:0:19,348 - [parse4cn1] Raw response (as string): {"createdAt":"2016-03-08T21:22:52.196Z","objectId":"iLrvfxWiYm"}
Any idea what might be going wrong and/or how I can debug this problem in more detail?
The above problem disappeared after I hosted the corresponding .war generated by the CN1 build server on open shift (based on this tutorial). So I guess it had to do with the preview html file... strange... but it works now.

Yeoman with grunt-connect-proxy returns a ECONNREFUSED error

I'm trying to add grunt-connect-proxy to a project that uses the latest yeoman + angular generator.
But, when hitting the road that should be forwarded (e.g. 127.0.0.1:9000/api/v1), the server returns this error:
An error has occurred: {"code":"ECONNREFUSED","errno":"ECONNREFUSED","syscall":"connect"}
I used a modified Gruntfile: same as here as recommended.
How I'm a supposed to debug this? Has anyone had a similar issue lately with grunt-connect-proxy?
I'm also interested in similar solutions for proxing api calls for an angular webapp, if you have any that actually work.
Thank you for helping me out! Much appreciated!
Gruntfile is fine, the error is caused by your backend, i.e. localhost:3000 (probably Rails).
If it is Rails, it's a CORS problem. You need to allow rails to accept connection from grunt server. Add 'rack-cors' to your gemfile and configure it like this in your development.rb config file:
config.middleware.use Rack::Cors do
allow do
origins 'localhost:9000'
resource '*', :headers => :any, :methods => [:get, :post, :options, :delete]
end
end
Check this link for detailed setup, it helped me to get it working.
Working with Angular.js and Rails
I was running into this issue while trying to develop locally using AngularJS with a Laravel backend.
I was able to get the grunt-conenct-proxy example working using the before mentioned Rails example: Working with Angular.js and Rails, however when trying to connect locally to my laravel backend I would always get the ECONNREFUSED error.
The only real difference I could see was that the rails server was spinning up on 0.0.0.0. where as my apache server was running on localhost/127.0.0.1. After changing my config for my apache sever to run at 0.0.0.0 using:
php artisan serve --host 0.0.0.0
I was the able to connect to my backed without issue. If anyone could comment and explain how/why this works I would be very grateful.
Well, I finally got it to work somehow.
But frankly, I don't get it. It was definitely related to localhost not being the same as 127.0.0.1. How did it ended that way, I don't have a clue...
I'll share what I learned while doing this, as I found no real answer for debugging this staff out there on the web. Here is what I learned:
grunt has a --verbose option that may help you see what's going on
If grunt-connect-proxy is configured correctly you must see something like this at startup:
Running "configureProxies" task
Proxy created for: /api/v1 to localhost:8000
In my case, the grunt server was running on 127.0.0.1:9000, the second server on localhost:8000. I proxied requests made on api/v1 so grunt server --verbose would output something like this on every proxied request:
Proxied request: /api/v1/test -> http://localhost:8000/api/v1/test
{
"host": "127.0.0.1:9000",
"connection": "keep-alive",
"accept": "...",
"user-agent": "...",
"accept-encoding": "...",
"accept-language": "...",
"cookie": "..."
}
the whole point of using a proxy is to avoid any unnecessary CORS configuration on your second server
This is because once deployed your frontend and backend code will coexist on the same server (= the grunt server is only needed at dev time). I wanted to stress that point, because #Ulugbek answer may suggest that you need CORS to make grunt-connect-proxy work.
the ECONNREFUSED error happens when your second server is not responding
In my case, I discovered that http://127.0.0.1:8000/api/v1/test was not responding even if http://localhost:8000/api/v1/test was. So, I messed around with the /etc/hosts a bit and solved the problem by making sure both endpoints were responding accordingly.
The same error may happen to you if the second server is not listening to the proxied endpoint.

Resources