# Java + wiremock: SocketTimeOut

**URL:** https://travis-ci.community/t/java-wiremock-sockettimeout/9163
**Category:** Java
**Tags:** build-env, bug
**Created:** [June 29, 2020, 6:38am UTC](https://travis-ci.community/t/java-wiremock-sockettimeout/9163 "2020-06-29T06:38:38Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![bmarwell](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/bmarwell/32/4857_2.png) [@bmarwell](https://travis-ci.community/u/bmarwell)
#### Post date: [June 29, 2020, 6:38am UTC](https://travis-ci.community/t/java-wiremock-sockettimeout/9163/1 "2020-06-29T06:38:38Z")

</div>

Hi,

I am using wiremock to test a restful API.  
For some reason, the build fails connecting to wiremock on localhost:8080 (or any other port) with this error message:

Caused by: java.net.SocketTimeoutException: SocketTimeoutException invoking [http://localhost:40705/index.cgi](http://localhost:40705/index.cgi)

Example build:  
[https://travis-ci.org/github/bmhm/j9kwsolver/builds/703051983](https://travis-ci.org/github/bmhm/j9kwsolver/builds/703051983)

I tried to configure wiremock to localhost explicitly, I added a dynamic port option. But no luck.  
Ideas what went wrong are very welcome. Haven’t seen this before with similar setups.

---

<div class="post-metadata">

### Author: ![Montana](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/montana/32/9566_2.png) [@Montana](https://travis-ci.community/u/Montana)
#### Post date: [June 29, 2020, 8:47am UTC](https://travis-ci.community/t/java-wiremock-sockettimeout/9163/2 "2020-06-29T08:47:48Z")

</div>

> [@bmarwell](#):
>
> Caused by: java.net.SocketTimeoutException: SocketTimeoutException invoking [http://localhost:40705/index.cgi](http://localhost:40705/index.cgi)

Have you tried to set the timeout for longer?

---

<div class="post-metadata">

### Author: ![bmarwell](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/bmarwell/32/4857_2.png) [@bmarwell](https://travis-ci.community/u/bmarwell)
#### Post date: [June 29, 2020, 9:08am UTC](https://travis-ci.community/t/java-wiremock-sockettimeout/9163/3 "2020-06-29T09:08:00Z")

</div>

Ah, good point. I remember now that I reduced the defaults to 100ms connection timeout and 500ms read timeout. Interstingly, this is still far more than I need for both local tests and integration tests, but may not work well with the travis environment for some reason.

The build finished while writing this answer. Works fine now. Thanks! 🙂

[https://travis-ci.org/github/bmhm/j9kwsolver/jobs/703093254](https://travis-ci.org/github/bmhm/j9kwsolver/jobs/703093254)
