I'm working on an app, where I have lot of async calls to our server.
My problem is that many of these calls uses a token, and for everytime I call the server with a token, I will receive a new token. This means that my async calls get synchronized because they new the newest token.
I'm using Jonathan Willings code from here: https://gist.github.com/jwilling/7209108
This is ok, but it blocks my UI and I cannot figure out why.
Can anybody help me? Thanks in advance!
Sorry for the unclear question. I'm using the ASIFormDataRequest. I got it working by using a semaphore answered in this https://stackoverflow.com/questions/23021948/objective-c-possible-to-queue-async-nsurlrequests). It's important though to reset the semaphore everytime, so that the signal doesn't increment for every time no calls are waiting.
Related
I got into work today and got a telling off from my boss because the company website wasn't loading properly on mobile. I looked in the console and saw the following error... Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.. I clicked the link https://xhr.spec.whatwg.org/#xmlhttprequest and the update was made yesterday (7th June 2016). How do I fix this error?
Usually the message you provided should not break a page from being rendered.
It just states that you should not use Synchronous XMLHttpRequest.
Synchronous requests will slow down rendering since the site has to wait for each request to complete in an iterative manner.
To "fix" that all your AJAX requests must be set to be async.
I am new to objective c. I have implemented in app purchase for different products in my application. It works fine, but sometimes the SKTransactionComplete methods which confirm the transaction are not called. I wonder if it's coding error, than why all the time it is successful but fail to response seldom?
Please give me some idea to debug the error.
Thanks in advance.
I am making a GET request to the following url:
http://testsurveys.com/surveys/demo-survey/?collector=10720
and the request works fine. The point is to assign collector ID 10720 to the survey. There is absolutely no issue with this request. However, when I add another parameter the collector ID is passed through as a get parameter but it does nothing. For example:
http://testsurveys.com/surveys/demo-survey/?code=123456&collector=10720
Why does the collector parameter work in the first scenario but not in the second?
That would depend on the code in your backend. There's nothing wrong with the second request. The fact that the parameters do get through to the other end is evidence of this. Try looking at your backend code and see why it isn't being processed properly. Were you coding it with any assumptions in mind that you ended up changing later? If you don't find anything, include the code in your question.
We are developing a private app for use with our Shopify store. To ensure we don't cross the API limits, we've implemented a basic configurable delay per API call.
We started with the documented API limit of 500 calls every 5 minutes, which mapped to a delay of 600ms per call. However, after 50 calls the server doesn't respond to the HTTP GET.
Even after we increased the delay to 1200ms per API call, it still fails after 50 calls.
We are using the Shopify4J on a store that is in a trial period (myfirststore-3).
I've looked at the wiki, api docs, forums and SO - but there is no mention of any other limit except the official 500/5min limit.
Are we running into a different call limit for private apps or trial stores ?
It seems the problem is in the java client implementation itself. We figured this out by adding all initializations inside our loop.
After making that change, we were able to make up to 500 API call per 5 minutes as documented.
We had added the apache httpclient library to the Shopify4J package to make it work on our backend servers, and it probably needs some tweaking. Ofcourse this is not a long term solution to our problem but it does answer this question.
Once we figure out the problem in our code, will post a comment here.
I'm using Netty to write a client application that sends UDP messages to a server. In short I'm using this piece of code to write the stream to the channel:
ChannelFuture future = channel.write(request, remoteInetSocketAddress);
future.awaitUninterruptibly(timeout);
if(!future.isDone()){
//abort logic
}
Everything works fine, but one thing: I'm unable to test the abort logic as I cannot make the write to fail - i.e. even if the server is down the future would be completed successfully. The write operation usually takes about 1 ms so setting very little timeout doesn't help too much.
I know the preffered way would be to use an asynch model instead of await() call, however for my scenario I need it to be synchronous and I need to be sure it get finnished at some point.
Does anyone know how could I simulate an uncompleted future?
Many thanks in advance!
MM
Depending on how your code is written you could use a mock framework such as mockito. If that is not possible, you can also use a "connected" UDP socket, i.e. a datagram socket that is bound to a local address. If you send to a bogus server you should get PortunreachableException or something similar.
Netty has a class FailedFuture that can be used for the purpose of this,
You can for example mock your class with tests that simulate the following:
ChannelFuture future;
if(ALWAYS_FAIL) {
future = channel.newFailedFuture(new Exception("I failed"));
else
future = channel.write(request, remoteInetSocketAddress);