Skip to content

All new connections stall if IOC is not opening channels #36

@willrogers

Description

@willrogers

We have a specific problem that is causing problems making connections in CS-Studio.

An IOC is responding to UDP broadcasts, but it is then not possible to open a channel using SocketChannel.open(), which times out after some unspecified time, about 1 minute in this case. Because the code in CAConnector.java calls SocketChannel.open() three times in succession, JCA takes 3 minutes before it fails and tries again to make a connection. If there are multiple channels from the same IOC it will effectively block all new connections in CS-Studio.

The least invasive way to improve this is to put a timeout on these connections, which can be done something like this:

SocketChannel sc = SelectorProvider.provider().openSocketChannel();
sc.configureBlocking(false);
sc.connect(address);
for (int i = 0; i < 20; i++) {
    if (sc.finishConnect()) {
         return sc;
    }
    Thread.sleep(50);
}

Returning the SocketChannel before it has connected is more tricky.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions