0

We are using PlayFramework to develop a Java APIS.

The problem we are facing when we call the WS api for getting the data from third party API.

private Stream<PostData> select(EntityManager em) {
    myClient.doGetCall(); //Rest api call 1
    myClient.doGetCall(); //Rest api call 2
    myClient.doGetCall(); //Rest api call 3
    myClient.doGetCall(); //Rest api call 4

    System.out.println("done");

    TypedQuery<PostData> query = em.createQuery("SELECT p FROM PostData p", PostData.class);
    return query.getResultList().stream();
}

When we call this API, it gives 504 time out. But if I call single api it works

private Stream<PostData> select(EntityManager em) {
    System.out.println("done");

    myClient.doGetCall(); //Rest api call 1

    TypedQuery<PostData> query = em.createQuery("SELECT p FROM PostData p", PostData.class);
    return query.getResultList().stream();
}

So the error is not coming in the internal api call using WS. But error is coming in the main REST-API developed in the play-framework.

Not sure what wrong in the this. Please help us out. Thanks in advance.

android_griezmann
  • 3,757
  • 4
  • 16
  • 43
  • That seems to indicate that the third party API you're calling cannot cope (with as much) parallel requests that you fire at them. Maybe it's rate limited? – cbley Jun 18 '20 at 10:07
  • @cbley no if I call that third party api in different application, it just work fine, even in 100 time for loop. – android_griezmann Jun 18 '20 at 10:14
  • A 504 error indicates there is a gateway or proxy between the requested service and the client. Are you using a proxy? Otherwise, you probably would have to show more (real) code. It seems as if you call `myClient.doGetCall()` just for its side-effects... ? What does this method actually do? Is it run async? Where exactly do you get the 504 from? – cbley Jun 18 '20 at 12:39

0 Answers0