Skip to main content

Selector.open call failing in Windows Azure

2 replies [Last post]
groovyfellow
Offline
Joined: 2010-03-28

I am trying to move a Java program to Windows Azure and it is failing in the nio call Selector.open. I am getting the following error returned:

Caused by: org.apache.mina.core.RuntimeIoException: Failed to open a selector.;
at org.apache.mina.transport.socket.nio.NioProcessor.(NioProcessor.java:58);
... 17 more;
Caused by: java.io.IOException: Unable to establish loopback connection;
at sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:106);
at java.security.AccessController.doPrivileged(Native Method);
at sun.nio.ch.PipeImpl.(PipeImpl.java:122);
at sun.nio.ch.SelectorProviderImpl.openPipe(SelectorProviderImpl.java:27);
at java.nio.channels.Pipe.open(Pipe.java:133);
at sun.nio.ch.WindowsSelectorImpl.(WindowsSelectorImpl.java:104);
at sun.nio.ch.WindowsSelectorProvider.openSelector(WindowsSelectorProvider.java:26);
at java.nio.channels.Selector.open(Selector.java:209);
at org.apache.mina.transport.socket.nio.NioProcessor.(NioProcessor.java:56);

I have put together a small test program that demonstrates the problem (see below). When I run this program locally in the Development environment it works fine, but when I deploy this to Azure I get the following error reported: Unable to establish loopback connection;

I am using version Java SE 1.6.0_18.

import java.nio.channels.Selector;
import java.io.*;

public class GatewayTest {

public static void main(String[] args) throws IOException {
try {
Selector.open();
System.out.println("Successfully opened Selector");
}
catch (Exception e) {
System.err.println("Unable to open Selector:\n" + e.getMessage());
System.exit(1);
}
}
}

I have posted this problem on the Azure forum and have received the following from Microsoft:
From some quick searching, it looks like Selector.open listens on a randomly picked localhost socket and creates a loopback connection to it. If that is the case ( I don't know whether that is and I would love some Java experts to confirm), this is not going to work as only ports that have been specified in the service model will work. Even if they are only loopback connections.

Can anybody confirm the behavior of Selector.open as described above? Any suggestions for ways around this problem are gladly accepted.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
shtarkar
Offline
Joined: 2010-06-04

Hello groovyfellow,
Curious to know what solution did you finally go with.

We have deployed our application to Azure platform. It uses AsyncHTTPClient calls and fails with the same issue as yours. Any suggestions would be appreciated.

alanb
Offline
Joined: 2005-08-08

On Windows, each Selector has a loopback connection that it used by the Selector wakeup mechanism so it means the firewall will need to be setup to allow loopback connections - sorry!