Define timeout on AsyncTask function - android-asynctask

I want my application to throw a timeout error within 15 seconds of it connecting to the webservice regardless whether the webservice has returned any answer or not.
Please comment in case anyone needs more details about the same!

Related

Why do I get a timeout error in Sinch?

I am trying to implement a video chat on my website. The user handling is done by my backend which creates a "signedUserTicket" and that ticket is then used to start the sinchClient. However when I try starting a call just after the message
Successfully initiated call, waiting for MXP signalling.
I get an error saying
Call PROGRESSING timeout. Will hangup call.
Also I get a Chrome warning saying
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience.
(But I don't think this is the reason for the timeout.)
So after checking in the network tab to find out whether the requests are correctly sent I realized that the problem is always with the requests going to https://rebtelsdk.pubnub.com. For example the request to https://rebtelsdk.pubnub.com/subscribe/sub-c-56224c36-d446-11e3-a531-02ee2ddab7fe/f590205a-c82d-4ec1-bd72-f2997097cbedS/0/14932956939626496?uuid=3b47f938-609d-4940-bb0e-bd7030cb3697&pnsdk=PubNub-JS-Web%2F3.7.2 takes about 20 seconds and it seems to cancel the requests after about 10 seconds giving me the timeout error.
Any ideas on how to fix this?

How defensive to be when interacting with another internal microservice?

In this scenario there are two HTTP microservices:
The public service that provides the client with data
The internal microservice that authenticates calls to the public service
Service 1 makes a call to Service 2 to ask it to authenticate the token provided to it by the client.
The agreement ("contract") is that Service 2 should reply with 200 OK and JSON content about the authenticated user.
In Service 1, if it receives the response 200 OK, is it worth going any further to validate the response further?
For example, the JSON body of the response is parsed into an object. Is there value in checking if that object was correctly instantiated instead of being set to null? Or alternatively should that be left to integration tests?
Strictly, a 200 only means that the request was successfully processed. This is regardless of the actual outcome of the call from a business perspective.
You are in effect relying on a convention of "we will throw an exception or otherwise fail the call if the user is not authenticated", to authenticate users.
Depending on the convention, you could conceivably have a scenario where a user was unauthenticated but the call was still successfully processed.
From this perspective, it may be worth having the service2 return a response which could then be interrogated to close this circle.
Alternatively, you could have the client call the authentication service directly, retrieve a token, and then present this token with any other request. This would mean that service1 is no longer responsible for having to know that a caller is authenticated.
The question is whether or not to then test in Service 1 each time the
response is received
Sorry, I would appear to have misunderstood the spirit of the question somewhat.
I am slightly confused - are you asking that, if the system under test is service1 then should any response from service2 also be part of that test?
I would say you would have to have some test which could prove that the sercvice2 response interrogation logic is correct, but this could be done at the unit test level. I don't think you'd need to do this for tests running against a deployed instance of the service, which is by nature more about the service behaviour at the boundary rather than internally.
Well your approach is not that bad!
Some of the HTTP status codes are reserved for cases of malformed requests etc. but in your case, you ask Service2 to return information for a token! If that token exists, you specified correctly, that Service2 has to return 200 OK. Now you just need to specify what happens if the token is not valid anymore or if it does not exists (or treat both cases the same...). If you specify, that Service2 has to return 404 Not found if it does not know the token or that the token expired, there (in most cases) is no need for Service1 to go any further! Parsing the status code is cheap in almost any language/environment, but forcing the deserialization of the content in both success and error cases is in comparison very expensive. Authentication needs to be fast - so I'd go for the status code here!
The key is, that this behavior has to be specified somewhere! (We went for swagger definitions!)

Timed out error in parse cloud when calling an http request inside an aftersave method

In my cloud code I do some things inside an after save method:
send 2 emails in parallel and an http request to create a calendar with google calendar, the problem is when doing the http request to create the calendar it returns a timed out error. I know parse have limits to 3 seconds for after save method, but my question is. How I make requests that last longer than three seconds?
You cannot overcome the request time-out limit on Parse. Parse is shutting down in less than a year, so you better move to a platform that has longer time-outs. I think on Backendless platform, the function time-out is 5 seconds.

JMeter page response is not complete or empty, what to do?

I'm running my JMeter scripts for only 5 virtual users. The scenario is: each user logs in to a system using credentials, checks some boxes and clicks the submit button. For the first 4 users, it works fine. I could see the successful submit button response. But often time for the last user, it seems the response page is not complete, though there's no errors.
Can anyone please tell me how can I ensure a complete page response? I'm attaching a screenshot if that helps.
Thanks!
--Ishti
With the listener on the thread where the request is sent, you might find the thread has been terminated before the response has been consumed.
You have another results tree listener at global scope, does it show the response?
Check jmeter.log to determine the time the thread ended.
Try adding a post-processor to force the thread to wait for response.

Abort HTTP-Request Server process

As shown in Abort DoJo XHR-Request it is possible to cancel a (dojo/request/xhr) http request on the Client.
The problem is, that the according server process (initiated by the request) is still running.
If we use a XMLHttpRequest-Object, calling abort() on it would stop the server process.
So the question is: Is it possible to achive this with dojo? Or is it possible to get access to the internal XMLHttpRequest-Object (used by dojo/request/xhr) to call abort() on it?

Resources