I have a program written in angular, and because im doing something in the browser that takes some time im getting 504 gateway timeout...how can I make the timeout bigger?
This is an error message produced by the server and needs to be fixed there.
See for example https://www.scalescale.com/tips/nginx/504-gateway-time-out-using-nginx/
This error is coming from service, you cannot handle from UI. This needs to be fixed from backend. However you can handle this kind of errors in UI.
.success( function( data, status, headers, config )
status will give you all status codes.
For more Info click here
Related
Is it possible to call Oracle Rest Data Services(ORDS) from React JS? I tried using axios and I have received "Network Error" in console, and in network tab I get code 304. I also tried using fetch and get the same http code and in console I have "net::ERR_CERT_COMMON_NAME_INVALID". So, my question is it is even possible to make this call or do I have to find a workaround? Any ideas?
Thanks!
I'm using the network calls and adding the following statements before reading the response.
r.setReadResponseForErrors(true);
r.setFailSilently(true);
NetworkManager.getInstance().addToQueueAndWait(r);
I don't want to show network error on Mobile App to the user but want to read the response code and perform the operation accordingly. Does this order matters? or do I have to setFailSilently() before setReadResponseForErrors? Please advise.
Thanks
You've mentioned this in another question where I literally quoted the code of fail silently...
You probably have a network manager listener probably in your init method where you show a generic error. That's part of the application boilerplate code.
I am developing an Angular JS application using ionic. For android, I am using crosswalk for better performance.
I've noticed that when running on Android, I am facing problems with http requests getting stuck when trying to load large images - if any request gets "stuck" -- i.e. no error, but in my chrome developer inspector, I see the http request as "pending" -- then all subsequent requests go into "pending" state too. This problem does not exist in iOS
The code is pretty simple:
<span ng-repeat="monitor in monitors">
<img ng-src="http://server.com/monitorId=monitor?view=jpg" />
</span>
This results in around 6 GETs of images of size 600x400 and the images keep changing (the server keeps changing the image)
What I've observed specifically with Android is after a few successful iterations, the network HTTP GET behind this img ng-src gets stuck in pending like I said above and then all subsequent HTTP requests also get into pending and none of them ever get out of that state.
I am guessing there is some sort of limit for network queue that is getting filled up.
So how do I solve this issue?
a) One way I could think of is to put a timeout -- but ng-src does not seem to have a time out function. My thought is on timeout, the http request would cancel - like in normal $http.get functions and this should help.
b) Maybe there is a way to flush all http requests. I saw in SO, someone created a new directive which needs to be added here: AngularJS abort all pending $http requests on route change --> but this needs me to replace http with this new directive --> while I am using img ng-src
c) Neither a nor c are ideal. I'd like to know what is really going on - why does Android balk at this while iOS does not (comparing Galaxy S3 with iPhone 5s). So if you have any other solutions, I'd love to hear them
thanks
Wow, this was quite a learning. I managed to implement a work-around.
Edited: For those who think this is due to the limitation of 6 connections- please go through https://code.google.com/p/chromium/issues/detail?id=234779
The problem specifically is Chrome (At least with crosswalk, and maybe chrome in general) has a problem if you open multiple streams of HTTP connections that don't close for a long time. In my case the "img-src" was pointing to an image URL that the server was changing 3 times a second. Each image takes a second or two to download, so data keeps streaming in.
There is something about this that puts Chrome in a tizzy and it starts getting into an eternal pending loop for any HTTP requests after the first pending - even unrelated HTTP requests
Fortunately, I managed to implement a workaround: The server had an option to just get one image (not dynamic). I used that URL and the implemented a $interval timer in that controller that would refresh that URL every second - effectively retrieving images every second (or any other timer value I want)
Chrome has NO problem dealing with the HTTP requests in this way because they are getting closed predictably, even if it means more HTTP requests.
Phew. Not the solution I'd want, but it works very well.
And the gallant iOS handles this well too (it handled the original scenario perfectly too)
In an Angular JS app I'm working on, I am using a service to periodically (in a $timeout) make a GET request to a URL in my API (both the Angular app and the API are being served from port 5000 on localhost).
For some reason, it appears that $http is not actually sending the GET. For each $http.get(), the .error() is called with empty data and a status of 0. When I check in my server log (I'm running a Ruby on Rails backend with the Unicorn gem for my server), it appears that the server never receives the request from Angular.
Here's the function in my service:
updateUserStatus = () ->
$http.get('/api/v1/status').success (statusData) ->
# update the variable and notify the observers
this.userStatus = statusData
notifyObservers()
startStatusTimeout()
.error (error, status) ->
# if there's an error, log it
console.log 'error:'
console.log error
console.log status
startStatusTimeout()
What's really odd is that it only happens sometimes. When it stops working, I can change the URL in the $http.get() to '/api/v1/status.json', and it works. For a while. Then I switch it back and it works again, for a while... obviously there is some greater issue at play.
I've been racking my brain for a few days now, and I've seen a bunch of similar issues on SO, but they all seem to be solved with implementing CORS in Angular, which I don't think is applicable to my situation because it's all coming from localhost:5000. Am I wrong? What's going on?
For reference, I'm using Angular version 1.0.7.
I had the same problem.
Check your code to see whether this happens after events that are fired from the DOM and are unknown to Angular.
If so, you need to add $scope.$apply(); after the get request in order to make it happen.
I'm fairly new to Angular so I'm not sure this is the best practice for using Angular, but it did work in my case.
See this similar question for a better explanation.
I've got a bit of a strange issue with iOS safari and backbone.js.
I am trying to fetch a collection via a post command, my backbone code is
MyApp.search_results.fetch({data: data,type: 'POST',
success: function(response){
//I do a bunch of stuff with success
},
error: function(){
alert('problem getting search');
}
});
when I run the above code in chrome (both desktop and in iPhone or Android) I get the result no problem.
But using safari on iOS, I get Failed to load resource: the server responded with a status of 404 (Not Found).
The big problem is my rails console does not even show that safari is sending the request, I see nothing past the previous request, so I'm getting a 404 error, but that actually isn't the problem.
Any ideas?
------------------------ update -----------------------
the problem is somehow caused by the type: 'POST'. I have removed and am now submitting a get request, but I would prefer this being a post type. So any suggestions on how to fix that would be great.
Backbone internally set's the request method to GET for the fetch function. Trying to override it can cause any number of inconsistencies and is not recommended.
If you're trying to fetch data, then why not update your server code to read the GET params instead of POST params (or both)?