PATCH request Unexpected EOF read on the socket

Hi,

I’m trying to route a PATCH request through a channel. This channel has a route to a spring RestController:

@RestController
public class PatchResource {

    Logger logger = LoggerFactory.getLogger(getClass());

    @PatchMapping(path = "/")
    public ResponseEntity patch(@RequestBody Map<String, Object> propertyValues) {
        logger.info("{}", propertyValues);
        return ResponseEntity.ok().body(propertyValues);
    }
}

When calling the endpoint directly, it returns the expected response:

$ docker exec -it openhim-core curl -X PATCH -H "Content-Type:application/json" -d '{"hello":"world"}' http://patch-test:8080/
{"hello":"world"}

When calling through OpenHIM,

docker exec -it openhim-core curl -X PATCH -H "Content-Type:application/json" -d '{"hello":"world"}' http://localhost:5001/patch-test

the request fails on the endpoint with the following error:

openhim-patch-test-1 | 2024-01-08 08:41:08.811 WARN 1 --- [nio-8080-exec-2] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: I/O error while reading input message; nested exception is java.io.EOFException: Unexpected EOF read on the socket

Increasing the channel timeout does not solve the issue.

Using core v8.4.0 on docker.

@ryan

1 Like

@richard.langford @gloria.makeleni @chris could you help with guidance on this?

Hi,

I get similar results with this mediator:

app.all("*", (_req, res) => {
    if(!_req.body) {
      res.status(400).json({error: "No request body"});
    }
    res.status(200);
});

Hi, I have tried this out myself and I get the same error. It seems this is a bug in the OpenHIM. Please could you capture this and a issue on Github and I’ll see that is addressed.

Sorry for the delayed response.

1 Like

Hi,

Here is the GitHub issue: Missing request body in PATCH requests · Issue #1217 · jembi/openhim-core-js · GitHub