http
http copied to clipboard
jruby-9.1.15.0 getting timeouts talking to Java/Jetty server, but ONLY when passing in timeout options
Hi all, in our app we are using HTTP to talk to a java BRMS/Rules server. We randomly encounter errors at times which return a "bad_record_mac" error. After googling and tinkering for hours with no luck, I started tweaking our HTTP calls we are making.
I found that if we pass in timeout options, the request fails every time! It currently fails on the Java/Jetty side at 60 seconds timeout and we confirmed from their end that the request just isn't coming through.
When I set the read timeout option to lower than 60, it raises that timeout error.
When I remove the timeout options, it works perfectly fine!
Here is our code:
HTTP.headers(content_type: :json, accept: :json, authorization: auth_header)
.timeout(write: 10, connect: 10, read: 300)
.send(http_method, @url_base + @url_query, json: @data)
Where "http_method" will resolve to either :get or :post This fails. Any other combination of timeouts fails. But removing the timeout options causes it to be successful.
Note that bad_record_mac
is a very bad sign which indicates data is getting mangled somewhere.
Just to rule out that it isn't the remote service or an intermediate network device, have you tried making the same requests with e.g. curl?