Skip to content

A client hang indefinitely if the server never reply #669

Closed
@avandecreme

Description

@avandecreme

Here is a small example:

Server side:

public class DummyServerResource extends ServerResource {

    @Get
    public String retrieve() {
        System.exit(0);
        return "Dummy";
    }
}

Client side:

    public static void main(String[] args) throws IOException {
        Client client = new Client(Protocol.HTTP);
        ClientResource cr = new ClientResource("http://localhost:8182/resttest/dummy");
        cr.setNext(client);
        Representation get = cr.get();
        System.out.println(get.getText());
    }

Looking in the ConnectionController class, I found a possible explication for the issue. The selectKeys method has a sleepTime parameter which is never used.
If I use it as a parameter of the select method, it seems to fix the problem:

        int selectCount = getSelector().select(sleepTime);

But this line has been modified on purpose on July to reduce CPU consumption, so I guess it is not a valid fix.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions