symphonyoss / symphony-java-client

Java client library for Symphony
Apache License 2.0
34 stars 37 forks source link

HTTP 400 datafeed #109

Open eric-moritz opened 6 years ago

eric-moritz commented 6 years ago

Using 1.1.4 and getting "INFO HTTP Status: 400; URL: /agent/v4/datafeed/e208693d-a98b-42b1-b1a5-b5d67abeffde/read; user: mybot.uat; OBO App: N/A" errors on a regular basis. ...

SymMessage message = new SymMessage();
message.setMessageText(ApiVersion.V4, msg);
SymStream stream = symClient.getStreamsClient().getStreamFromEmail(to);
symClient.getMessagesClient().sendMessage(stream, message);
result = sent.getId();

2018-03-16 09:44:27.814 INFO 24847 --- [ Thread-4] o.s.client.services.MessageFeedWorkerV2 : Creating datafeed with pod... 2018-03-16 09:44:58.406 ERROR 24847 --- [ Thread-4] o.s.client.services.MessageFeedWorkerV2 : Failed to create read datafeed from pod, please check connection..resetting.

org.symphonyoss.client.exceptions.DataFeedException: Failed to retrieve messages from datafeed... to https://server:8444/agent endpoint https://server:8444/agent httpStatus 400 at org.symphonyoss.symphony.clients.impl.DataFeedClientImpl.getMessagesFromDatafeed(DataFeedClientImpl.java:148) ~[symphony-client-1.0.3.jar!/:1.0.3] at org.symphonyoss.symphony.clients.impl.DataFeedClientImpl.getMessagesFromDatafeed(DataFeedClientImpl.java:159) ~[symphony-client-1.0.3.jar!/:1.0.3] at org.symphonyoss.client.services.MessageFeedWorkerV2.readDatafeed(MessageFeedWorkerV2.java:138) [symphony-client-1.0.3.jar!/:1.0.3] at org.symphonyoss.client.services.MessageFeedWorkerV2.run(MessageFeedWorkerV2.java:77) [symphony-client-1.0.3.jar!/:1.0.3] at java.lang.Thread.run(Thread.java:748) [na:1.8.0_161] Caused by: org.symphonyoss.symphony.agent.invoker.ApiException: {"code":400,"message":"Could not find a datafeed with the id: b7140cc2-2a9f-4c39-b1ac-bca07544d067"} at org.symphonyoss.symphony.agent.invoker.ApiClient.invokeAPI(ApiClient.java:708) ~[symphony-agent-java-jersey2-client-1.47.0.jar!/:1.47.0] at org.symphonyoss.symphony.agent.api.DatafeedApi.v2DatafeedIdReadGet(DatafeedApi.java:210) ~[symphony-agent-java-jersey2-client-1.47.0.jar!/:1.47.0] at org.symphonyoss.symphony.clients.impl.DataFeedClientImpl.getMessagesFromDatafeed(DataFeedClientImpl.java:145) ~[symphony-client-1.0.3.jar!/:1.0.3] ... 4 common frames omitted

pmonks commented 6 years ago

I'm seeing something similar, albeit with a 500 error:

Failed to create read datafeed from pod, please check connection..resetting.
org.symphonyoss.client.exceptions.DataFeedException: Failed to retrieve messages due to network issue.. to https://foundation-dev.symphony.com/agent
endpoint https://foundation-dev.symphony.com/agent
httpStatus 500
    at org.symphonyoss.symphony.clients.impl.DataFeedClientImpl.getEventsFromDatafeed(DataFeedClientImpl.java:135)
    at org.symphonyoss.symphony.clients.impl.DataFeedClientImpl.getEventsFromDatafeed(DataFeedClientImpl.java:145)
    at org.symphonyoss.client.services.DataFeedWorker.readDatafeed(DataFeedWorker.java:142)
    at org.symphonyoss.client.services.DataFeedWorker.run(DataFeedWorker.java:79)
    at java.lang.Thread.run(Thread.java:748)
Caused by: javax.ws.rs.ProcessingException: Error reading entity from input stream.
    at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:889)
    at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:834)
    at org.glassfish.jersey.client.ClientResponse.readEntity(ClientResponse.java:368)
    at org.glassfish.jersey.client.InboundJaxrsResponse$2.call(InboundJaxrsResponse.java:126)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:419)
    at org.glassfish.jersey.client.InboundJaxrsResponse.runInScopeIfPossible(InboundJaxrsResponse.java:267)
    at org.glassfish.jersey.client.InboundJaxrsResponse.readEntity(InboundJaxrsResponse.java:123)
    at org.symphonyoss.symphony.agent.invoker.ApiClient.deserialize(ApiClient.java:564)
    at org.symphonyoss.symphony.agent.invoker.ApiClient.invokeAPI(ApiClient.java:697)
    at org.symphonyoss.symphony.agent.api.DatafeedApi.v4DatafeedIdReadGet(DatafeedApi.java:321)
    at org.symphonyoss.symphony.clients.impl.DataFeedClientImpl.getEventsFromDatafeed(DataFeedClientImpl.java:127)
    ... 4 common frames omitted
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "messageId" (class org.symphonyoss.symphony.agent.model.V4Event), not marked as ignorable (6 known properties: "timestamp", "diagnostic", "type", "id", "payload", "initiator"])
 at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 30] (through reference chain: org.symphonyoss.symphony.agent.model.V4EventList[0]->org.symphonyoss.symphony.agent.model.V4Event["messageId"])
    at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:60)
    at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(DeserializationContext.java:822)
    at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:1152)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1582)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1560)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:294)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:286)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
    at com.fasterxml.jackson.databind.ObjectReader._bind(ObjectReader.java:1574)
    at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:965)
    at com.fasterxml.jackson.jaxrs.base.ProviderBase.readFrom(ProviderBase.java:815)
    at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.invokeReadFrom(ReaderInterceptorExecutor.java:256)
    at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:235)
    at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:155)
    at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1085)
    at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:874)
    ... 17 common frames omitted
ftbb commented 6 years ago

@eric-moritz sorry I didn't see this before..

You are not running 1.1.4, because the underlying jar's are showing 1.0.3.

You want to check your dependencies and make sure you just have the following:

<dependency>
<groupId>org.symphonyoss.symphony</groupId>
<artifactId>symphony-java-client</artifactId>
<version>1.1.4</version>
</dependency>

you can also run #mvn dependency:tree to list out all the extended dependencies.

ftbb commented 6 years ago

@pmonks you are suffering from a different issue.

You are most likely initializing your own HttpClient and overriding the defaults in the SymphonyClient instance. The issue is related to the fact you are not registering a configuration that ignores unknown properties.

So if you build your client by (short hand):

  ClientConfig clientConfig...;
  Json json = new Json()
  clientConfig.register(json);
  clientConfig.register(other stuff, like proxies..etc.)
  Client client = ClientBuilder.newClient(clientConfig);
  -----------------------
  public class JSON implements ContextResolver<ObjectMapper> {
  private ObjectMapper mapper = new ObjectMapper();

  public JSON() {
    this.mapper.setSerializationInclusion(Include.NON_NULL);
    this.mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    this.mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false);
    this.mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    this.mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
    this.mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
    this.mapper.setDateFormat(new RFC3339DateFormat());
    this.mapper.registerModule(new JavaTimeModule());
  }

  public void setDateFormat(DateFormat dateFormat) {
      this.mapper.setDateFormat(dateFormat);
  }

 public ObjectMapper getContext(Class<?> type) {
    return this.mapper;
  }
 }
pmonks commented 6 years ago

Thanks @ftbb!

My code is calling SymphonyClientFactory.getClient, passing in a type of V4.

Should I need to do the above configuration myself in this case?

pmonks commented 6 years ago

Thanks to offline assistance from @ftbb , this issue is now fixed in my code.

aditimithal commented 6 years ago

Hi @pmonks, I am facing the same issue - would you mind elaborating on how you fixed it? Thanks!

pmonks commented 6 years ago

@aditimithal this code shows the solution.

The full sequence for initialising SJC is here.