ActiveCampaign / postmark-java

Official Java client library for the Postmark HTTP API
https://postmarkapp.com
MIT License
35 stars 21 forks source link

HeaderValueException:Too many "Content-Type" header values: "[application/json, application/json]" #33

Closed ediweissmann closed 2 years ago

ediweissmann commented 3 years ago

Seeing this from time to time:

org.glassfish.jersey.message.internal.HeaderValueException:Too many "Content-Type" header values: "[application/json, application/json]"
org.glassfish.jersey.message.internal.OutboundMessageContext.singleHeader(OutboundMessageContext.java:199)
org.glassfish.jersey.message.internal.OutboundMessageContext.getMediaType(OutboundMessageContext.java:270)
org.glassfish.jersey.client.ClientRequest.ensureMediaType(ClientRequest.java:511)
org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:441)
org.glassfish.jersey.client.internal.HttpUrlConnector._apply(HttpUrlConnector.java:367)
org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:265)
org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:297)
org.glassfish.jersey.client.JerseyInvocation.lambda$invoke$1(JerseyInvocation.java:643)
org.glassfish.jersey.client.JerseyInvocation.call(JerseyInvocation.java:665)
org.glassfish.jersey.client.JerseyInvocation.lambda$runInScope$3(JerseyInvocation.java:659)
org.glassfish.jersey.internal.Errors.process(Errors.java:292)
org.glassfish.jersey.internal.Errors.process(Errors.java:274)
org.glassfish.jersey.internal.Errors.process(Errors.java:205)
org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:390)
org.glassfish.jersey.client.JerseyInvocation.runInScope(JerseyInvocation.java:659)
org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:642)
org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:445)
org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:346)
com.wildbit.java.postmark.client.HttpClient.execute(HttpClient.java:62)
com.wildbit.java.postmark.client.HttpClientHandler.execute(HttpClientHandler.java:62)
com.wildbit.java.postmark.client.ApiClient.deliverMessage(ApiClient.java:67)
ibalosh commented 2 years ago

Thank you for reporting this @ediweissmann

could you share bit more details on how you run the library so we can identify the issue. For example, are you using it in multithreading environment or something similar? If you could share also details about environment you use (Java version, etc) that would help us a lot too.

ediweissmann commented 2 years ago

Yes to multithreading environment (a java/scala web app), as in there can be multiple threads/requests calling the Postmark API client in parallel.

Is the client not thread-safe, should we take care of the synch access on our end?

java -version
Picked up JAVA_TOOL_OPTIONS: -Xmx100m -Xss512k -Djava.net.preferIPv4Stack=true
openjdk version "11.0.7" 2020-04-14 LTS
OpenJDK Runtime Environment Corretto-11.0.7.10.1 (build 11.0.7+10-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.7.10.1 (build 11.0.7+10-LTS, mixed mode)
ibalosh commented 2 years ago

Thanks @ediweissmann

client should be thread safe, but that was first to come to my mind related to issue. I will see to dig into this issue this week

ibalosh commented 2 years ago

Hi @ediweissmann

we just released version 1.7.6 which should resolve this issue. Let me know if works correctly for you.

Igor

ediweissmann commented 2 years ago

Thank you, will let you know if it happens after updating.

aonurozcan commented 2 years ago

Hello @ibalosh

We're using 1.8.0 version and still getting same error. Do you have any idea?

ibalosh commented 2 years ago

Hi @aonurozcan

unfortunately we can't reproduce the issue and haven't received any additional customer support regarding this issue. We will need to investigate it more

ibalosh commented 2 years ago

Hey guys,

in order to resolve this issue I would need as much details as possible from you so that we can reproduce it and fix it. We are not yet sure if the issue is coming from the library or from the API response for this specific case.

things that help

The more details you share, the easier we will track the issue down

Thanks

enkuru commented 2 years ago

Hey guys,

in order to resolve this issue I would need as much details as possible from you so that we can reproduce it and fix it. We are not yet sure if the issue is coming from the library or from the API response for this specific case.

things that help

  • exact Java version
  • library version (I am guessing latest)
  • in which period of the day you see the issue
  • any other specific libraries/environment you are using
  • what is the type of sending you do when you see the issue (batch, single emails, attachments, how big email messages, etc)
  • for which endpoints do you see the issue? (sending, templates, outbound messages, link tracking, stats, bounces, etc)
  • do you use windows, linux, mac environment, etc

The more details you share, the easier we will track the issue down

Thanks

java version: java-11-amazon-corretto library version: 1.8.0 in which period of the day you see the issue: it is randomly, we have simulated same failed request and it does successfully sent email any other specific libraries/environment you are using: spring boot 2.6.6 what is the type of sending you do when you see the issue: single emails with attachment for which endpoints do you see the issue?: sending mail do you use windows, linux, mac environment: we are using AWS Beanstalk with Amazon Linux 2/3.2.14

ibalosh commented 2 years ago

@enkuru could you also share how big is the email you are sending, body + attachment?

enkuru commented 2 years ago

@ibalosh sorry I have checked we don't send attachment, only template. So there is only body with 15 KB

ibalosh commented 2 years ago

np, @enkuru do you see this only when sending with templates, or you can see it on some other endpoints too?

enkuru commented 2 years ago

Hi, we saw it only sending with templates