Jackson JSON how to set http connection and read timeout Jackson JSON how to set http connection and read timeout json json

Jackson JSON how to set http connection and read timeout


You could hack the values

System.setProperty("sun.net.client.defaultConnectTimeout", "10000");System.setProperty("sun.net.client.defaultReadTimeout", "10000");

More on the settings can be found on https://docs.oracle.com/javase/7/docs/technotes/guides/net/properties.html

Or you can instead do a proper call and then pass the result into the json parser. I would go with the latter.

So to put it simply while URL is great light weight alternative I suggest switching to apache http client or some high level solution.


That particular read method is for convenience, but not configurable and generally not that useful for most production usage.

Instead, you may want to obtain InputStream from URL endpoints using other means, then pass it to ObjectMapper / ObjectReader; this allows for full control over details of connection, timeouts and so forth. It allows lets you use other HTTP clients than the default one JDK comes equipped with.