In a Google App Engine app I used the following lines to read a page from a site :
String Url="http://...",line,Result="";
URL url=new URL(Url+"?r="+System.currentTimeMillis());
BufferedReader reader=new BufferedReader(new InputStreamReader(url.openStream()));
while ((line=reader.readLine())!=null) { Result+=line+"\n"; }
reader.close();
But I got the following error :
Uncaught exception from servlet
com.google.apphosting.api.DeadlineExceededException: This request (f5e2889605d27d42) started at 2011/09/07 03:20:41.458 UTC and was still executing at 2011/09/07 03:21:30.888 UTC.
at sun.misc.Unsafe.park(Native Method)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedNanos(AbstractQueuedSynchronizer.java:1037)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireSharedNanos(AbstractQueuedSynchronizer.java:1326)
at com.google.common.util.concurrent.AbstractFuture$Sync.get(AbstractFuture.java:276)
at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:82)
at com.google.appengine.tools.development.TimedFuture.get(TimedFuture.java:55)
at com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:69)
at com.google.apphosting.runtime.ApiProxyImpl.doSyncCall(ApiProxyImpl.java:177)
at com.google.apphosting.runtime.ApiProxyImpl.access$000(ApiProxyImpl.java:56)
at com.google.apphosting.runtime.ApiProxyImpl$1.run(ApiProxyImpl.java:150)
at com.google.apphosting.runtime.ApiProxyImpl$1.run(ApiProxyImpl.java:148)
at java.security.AccessController.doPrivileged(Native Method)
Seems it took longer than it would like to wait, what can I do if that site is slow ?
A DeadlineExceededException is thrown when your code, handling the request to your web application takes over 30 seconds to process. Presumably your code is taking a while to process because of the length of time it had to wait to receive data from some other site.
You can create a task on a task queue to fetch and process that data, and change your web request/response flow to reply with progress on your task.
If your code is running inside a request handler, then by default there is an App-Engine-enforced 60 second deadline. You can't change it. See the "Deadlines" row / "automatic scaling" column of the chart on this page under "Scaling types":
https://developers.google.com/appengine/docs/java/modules/
However, this code will be able to run for some hours if you change your module to use "manual scaling" and a "B1"-"B4" instance. Example:
default/src/main/webapp/WEB-INF/appengine-web.xml:
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>myapp</application>
<module>default</module>
<version>1</version>
<threadsafe>true</threadsafe>
<instance-class>B1</instance-class>
<manual-scaling>
<instances>1</instances>
</manual-scaling>
</appengine-web-app>
On this type of instance, your requests will typically not time out for hours. (The documentation claims that the deadline is "indefinite".)
Related
I'm using RemoteAPI to fetch entities from GAE Datastore, 300 at a time.
I'm doing something along the lines of:
while(!(emails = getEmails()).isEmpty()) {
Filter filter = new FilterPredicate("email", FilterOperator.IN, emails)
Query query = new Query("MyEntity").setFilter(filter);
QueryResultIterable<Entity> result = ds.prepare(query).asQueryResultIterable();
for (Entity entity : result) {
System.out.println(entity.getProperty("name"));
}
}
I'm processing something like 50k emails. The first time I ran this code it got to maybe 3/4 of the way, then it threw the following exception. Now it throws it after a single loop iteration is run.
com.google.appengine.tools.remoteapi.RemoteApiException: remote API call: I/O error
at com.google.appengine.tools.remoteapi.RemoteRpc.makeException(RemoteRpc.java:160)
at com.google.appengine.tools.remoteapi.RemoteRpc.callImpl(RemoteRpc.java:104)
at com.google.appengine.tools.remoteapi.RemoteRpc.call(RemoteRpc.java:50)
at com.google.appengine.tools.remoteapi.RemoteDatastore.runQuery(RemoteDatastore.java:156)
at com.google.appengine.tools.remoteapi.RemoteDatastore.handleRunQuery(RemoteDatastore.java:115)
at com.google.appengine.tools.remoteapi.RemoteDatastore.handleDatastoreCall(RemoteDatastore.java:93)
at com.google.appengine.tools.remoteapi.RemoteApiDelegate.makeDefaultSyncCall(RemoteApiDelegate.java:57)
at com.google.appengine.tools.remoteapi.StandaloneRemoteApiDelegate.makeSyncCall(StandaloneRemoteApiDelegate.java:47)
at com.google.appengine.tools.remoteapi.StandaloneRemoteApiDelegate$1.call(StandaloneRemoteApiDelegate.java:58)
at com.google.appengine.tools.remoteapi.StandaloneRemoteApiDelegate$1.call(StandaloneRemoteApiDelegate.java:54)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:152)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at sun.security.ssl.InputRecord.readFully(InputRecord.java:442)
at sun.security.ssl.InputRecord.read(InputRecord.java:480)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:934)
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:891)
at sun.security.ssl.AppInputStream.read(AppInputStream.java:102)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:690)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1324)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338)
at com.google.appengine.repackaged.com.google.api.client.http.javanet.NetHttpResponse.<init>(NetHttpResponse.java:37)
at com.google.appengine.repackaged.com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:94)
at com.google.appengine.repackaged.com.google.api.client.http.HttpRequest.execute(HttpRequest.java:972)
at com.google.appengine.tools.remoteapi.OAuthClient.post(OAuthClient.java:54)
at com.google.appengine.tools.remoteapi.RemoteRpc.callImpl(RemoteRpc.java:102)
... 12 more
I can't figure out what the problem is, but the code seems to be evaluating the for() condition before throwing the exception.
Could this be a quota problem? The quota details screen doesn't show any problems and I can't find any relevant information in the documentation.
For future readers of this question, if you see occurrences of RemoteApiException: remote API call: I/O error which are happening consistently and not intermittently, this could be related to a disruption in network connectivity or possibly a remote issue on the App Engine side.
If the first possibility is ruled out, the best course of action is to report the issue on the Google App Engine issue tracker.
To fix this, first, check your Internet connection. Then clean all artifacts and build them again by (with IntelliJ):
Go to Build => Build Artifacts...
Focus on All Artifacts => Clean
Focus on All Artifacts => Build
As the title says, I'm trying to create a GAE + GWT project using Objectify but I can't even get it off the ground. I'm sure I'm missing something simple but doesn't seem to be working.
Here is what I've done so far:
Create a new project and added guava-17.0.jar, guava-gwt-17.0.jar, objectify-5.0.3.jar, and objectify-gwt-1.1jar to my WEB-INF\lib folder. These are all the latest versions of these jars.
Run the application. Send a simple RPC command, server responds, and client successfully receives response (onSuccess() is called).
Add the line <inherits name="com.googlecode.objectify.Objectify" /> to my gwt.xml file per Objectify-GWT's website which is supposed to enable Objectify in GWT.
Run the application. The application starts, same RPC command is sent, server receives and responds, but the client says the command was a failure (onFailure() is called).
I am using the boiler-plate code that is pre-populated when first create a new web application. For reference, here is the RPC command:
private void sendNameToServer() {
// First, we validate the input.
errorLabel.setText("");
String textToServer = nameField.getText();
if (!FieldVerifier.isValidName(textToServer)) {
errorLabel.setText("Please enter at least four characters");
return;
}
// Then, we send the input to the server.
sendButton.setEnabled(false);
textToServerLabel.setText(textToServer);
serverResponseLabel.setText("");
greetingService.greetServer(textToServer,
new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
// Show the RPC error message to the user
dialogBox
.setText("Remote Procedure Call - Failure");
serverResponseLabel
.addStyleName("serverResponseLabelError");
serverResponseLabel.setHTML(SERVER_ERROR);
dialogBox.center();
closeButton.setFocus(true);
}
public void onSuccess(String result) {
dialogBox.setText("Remote Procedure Call");
serverResponseLabel
.removeStyleName("serverResponseLabelError");
serverResponseLabel.setHTML(result);
dialogBox.center();
closeButton.setFocus(true);
}
});
}
This is the error I receive after I try to make the RPC call:
[DEBUG] [my_app] - Validating units:
[INFO] [my_app] - Module my_app has been loaded
[ERROR] [my_app] - Errors in 'com/google/gwt/dev/jjs/SourceOrigin.java'
[ERROR] [my_app] - Line 77: The method synchronizedMap(new LinkedHashMap<SourceOrigin,SourceOrigin>(){}) is undefined for the type Collections
[ERROR] [my_app] - Errors in 'com/google/gwt/dev/util/StringInterner.java'
[ERROR] [my_app] - Line 29: No source code is available for type com.google.gwt.thirdparty.guava.common.collect.Interner<E>; did you forget to inherit a required module?
[ERROR] [my_app] - Line 29: No source code is available for type com.google.gwt.thirdparty.guava.common.collect.Interners; did you forget to inherit a required module?
To me it looks like Objectify is interfering with GWT. I know they're supposed to work together so not sure what I'm doing wrong. Any advice would be appreciated.
Use objectify-gwt 1.2. It's possible that 1.1 has some issues from merging a bad PR.
You can see a sample application that uses objectify-gwt to pass a GeoPt back and forth from the client here: https://github.com/stickfigure/objectify-gwt-test
You should use objectify on the server side before trying to do this kind of stuff. Objectify is a server side peristence technology. Call it in your server code
add try catch in your service methods and print the stack trace of the exception on your server console, if you receive onFailure() on GWT that means there is a failure on the server side. You have to find what is that failure.
Now the second part is an advice:
<inherits name="com.googlecode.objectify.Objectify" />
Is a weired line for me. GWT doesn't have to know about your persistence layer.
Unless it's a revolutionary concept, I would recommend you d'ont use this type of technology that removes your hand from the controle of your db access...
We are using the following details for updating the quantity of a product in amazon. Wile using scratch pad, option Feeds->SubmitFeed
Set the required parameters and pass the following XML
<?xml version="1.0" encoding="utf-8" ?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>$merchantID</MerchantIdentifier>
</Header>
<MessageType>Inventory</MessageType>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
<Inventory>
<SKU>$SKU</SKU>
<Quantity>8</Quantity>
</Inventory>
</Message>
</AmazonEnvelope>
feed type : _POST_INVENTORY_AVAILABILITY_DATA_
we are getting in response for the same - submissionid. I know it takes sometime to update. But i waited and waited .. 4 atleast 15 hrs (not minutes) but it still was in process and the quantity was never updated.
Am getting in the following response
<?xml version="1.0"?>
<SubmitFeedResponse xmlns="http://mws.amazonaws.com/doc/2009-01-01/">
<SubmitFeedResult>
<FeedSubmissionInfo>
<FeedSubmissionId>6791310806</FeedSubmissionId>
<FeedType>_POST_INVENTORY_AVAILABILITY_DATA_</FeedType>
<SubmittedDate>2013-03-21T19:48:37+00:00</SubmittedDate>
<FeedProcessingStatus>_SUBMITTED_</FeedProcessingStatus>
</FeedSubmissionInfo>
</SubmitFeedResult>
<ResponseMetadata>
<RequestId>fd07bf18-4f6a-4786-bdf9-9d4db50956d0</RequestId>
</ResponseMetadata>
</SubmitFeedResponse>
and getting in following response on checking the status of the feed
<?xml version="1.0"?>
<ErrorResponse xmlns="http://mws.amazonaws.com/doc/2009-01-01/">
<Error>
<Type>Sender</Type>
<Code>FeedProcessingResultNotReady</Code>
<Message>Feed Submission Result is not ready for Feed Submission Id: 6791310806</Message>
<Detail/>
</Error>
<RequestID>2c86128d-b53a-4fc3-80d1-6b41b53a8977</RequestID>
</ErrorResponse>
Can any1 guide me.. where did i go wrong .. in here? or if there is any better way to look on for the same.
The time it seems to be taking isn't normal. Submitted feeds usually switch to _IN_PROGRESS_ within a few minutes and then take another few minutes to complete, when the status switches to _DONE_. Short feeds like your example feed should take less than a minute to process.
In the past, I've seen one feed upload blocking another though. It seems that sometimes the MWS won't start processing one feed until a previous feed of the same user has gone trough (or for that matter: failed). Please check if you have other request that might block yours (GetFeedSubmissionList)
Apart from this, the answers you are getting from Amazon MWS are perfectly normal. Your feed was accepted and put into the processing queue. The queue status was set to _SUBMITTED_, and as long as it hasn't switched to DONE, you will get the FeedProcessingResultNotReady answer you were seeing.
When creating a new bulk job through the API, I am getting an InvalidEntity as an exception code which isn't in SFDC's docs (pdf)
I'm making the following request
https://na13-api.salesforce.com/services/async/24.0/job
<?xml version="1.0" encoding="UTF-8"?>
<jobInfo xmlns="http://www.force.com/2009/06/asyncapi/dataload">
<operation>query</operation>
<object>Campaign</object>
<concurrencyMode>Parallel</concurrencyMode>
<contentType>CSV</contentType>
</jobInfo>
And I get this response:
<?xml version="1.0" encoding="UTF-8"?><error
xmlns="http://www.force.com/2009/06/asyncapi/dataload">
<exceptionCode>InvalidEntity</exceptionCode>
<exceptionMessage>Entity 'Campaign' is not supported by the Bulk API.</exceptionMessage>
</error>
I've excluded the headers but I do have accept & content encoding specified as gzip and the content is gzipped when it is sent and received.
The requests work correctly for
Lead
Contact
Opportunity
Task
Event
OpportunityContactRole
Account
CampaignMember
Note
Profile
RecordType
User
I only get the exception shown above for:
Campaign
UserLicense
OpportunityStage
OpportunityHistory
LeadHistory
I'm only using the bulk api to download csv's out of salesforce and I've only tried the above entities because I don't need any others.
It has been a very long time, but I think you can get this exception if one of your foreign key relationships is incorrect.
I am testing API Sample of Amazon MWS API in C# for submit feeds however after setting AWS Secret key , access key etc. in code i am getting error of RequestThrottled , so there is details what is that but could not find any code sample how to resolved that.
I would like to upload feed.xml to amazon seller account
<?xml version="1.0" encoding="iso-8859-1"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>M_EXAMPLE_123456</MerchantIdentifier>
</Header>
<MessageType>Product</MessageType>
<PurgeAndReplace>true</PurgeAndReplace>
<Message>
<MessageID>1</MessageID>
<OperationType>Insert</OperationType>
<Product>
<SKU>56789</SKU>
<StandardProductID>
<Type>ASIN</Type>
<Value>B0EXAMPLEG</Value>
</StandardProductID>
<ProductTaxCode>A_GEN_NOTAX</ProductTaxCode>
<DescriptionData>
<Title>Example Product Title</Title>
<Brand>Example Product Brand</Brand>
<Description>This is an example product description.</Description>
<BulletPoint>Example Bullet Point 1</BulletPoint>
<BulletPoint>Example Bullet Point 2</BulletPoint>
<MSRP currency="USD">25.19</MSRP>
<Manufacturer>Example Product Manufacturer</Manufacturer>
<ItemType>example-item-type</ItemType>
</DescriptionData>
<ProductData>
<Health>
<ProductType>
<HealthMisc>
<Ingredients>Example Ingredients</Ingredients>
<Directions>Example Directions</Directions>
</HealthMisc>
</ProductType>
</Health>
</ProductData>
</Product>
</Message>
</AmazonEnvelope>
Error getting as per below
Caught Exception: Request from SubmitFeed:AKIAJI4PSK4HXY6UCNMA;A2DNAGZJ1EWQLW is
throttled.
Response Status Code: ServiceUnavailable
Error Code: RequestThrottled
Error Type: Sender
Request ID: fc59c802-04da-4dd3-89a8-db5f525cac39
XML: <ErrorResponse xmlns="http://mws.amazonaws.com/doc/2009-01-01/"><Error><Typ
e>Sender</Type><Code>RequestThrottled</Code><Message>Request from SubmitFeed:AKI
AJI4PSK4HXY6UCNMA;A2DNAGZJ1EWQLW is throttled.</Message><Detail>System.Object</D
etail></Error><RequestId>fc59c802-04da-4dd3-89a8-db5f525cac39</RequestId></Error
Response>
How can this be resolved?
As per Amazon's API reference the SubmitFeed operation has a maximum request quota of 15 and a restore rate of a request every 2 minutes. This means that you're allowed to make calls to this operation in burst of 15, but after this you're throttled for 2 minutes, until Amazon allows you to make another request.
You can find this better explained in their developer guide where they describe better how they make use of the leaky bucket algorithm.
Probably there isn't anything wrong with your feed, but because you made too many requests (probably more than 15) you got throttled. My advice is to build your code in such a way that you take into consideration Amazon throttlening and have a back-off algorithm when you're being throttled (like come back after a "restore rate" period, specific to the type of call you're doing). Also, keep in mind that another limitation MWS has is of 10000 requests per hour across all type of calls.