5

I have installed the Proximo add-on on Heroku and when prepending the command to my existing command, I get a BindException from Java. This is how my prepended command looks: web: bin/proximo sh target/bin/webapp and as soon as I remove the Proximo part (bin/proximo), the application starts up with no errors.

This is the full stacktrace. What am I missing?

Exception in thread "main" java.net.BindException: Cannot assign requested address
 at sun.nio.ch.Net.bind0(Native Method)
 at sun.nio.ch.Net.bind(Net.java:344)
 at sun.nio.ch.Net.bind(Net.java:336)
 at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:199)
 at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
 at org.eclipse.jetty.server.nio.SelectChannelConnector.open(SelectChannelConnector.java:162)
 at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:297)
 at org.eclipse.jetty.server.nio.SelectChannelConnector.doStart(SelectChannelConnector.java:240)
 at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:58)
 at org.eclipse.jetty.server.Server.doStart(Server.java:270)
 at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:58)
Jonik
  • 80,077
  • 70
  • 264
  • 372

3 Answers3

1

Remember you can only use the port that Heroku provides in the $PORT var.

Therefore:

web: bin/proximo [your existing command]

needs to include this, e.g:

web: bin/proximo [your existing command] -p $PORT

or whatever you need to dictate the port your web process runs on.

Neil Middleton
  • 22,105
  • 18
  • 80
  • 134
0

It is something related to another process using port 9999. On Windows, run the command:

netstat -a -n | find "LIST"

And it should list anything there that's hogging the port. Of course you'll then have to go and manually kill those programs in Task Manager. If this still doesn't work, replace the line:

serverSocket = new ServerSocket(9999);

With:

InetAddress locIP = InetAddress.getByName("192.168.1.20");
serverSocket = new ServerSocket(9999, 0, locIP);

Use 127.0.0.1 with your actual IP address.

Harish Raj
  • 1,565
  • 3
  • 17
  • 27
  • Although I get the same exception as Visher in this post http://stackoverflow.com/questions/8965155/cannot-assign-requested-address-jvm-bind it is not the same issue. I am running a Java app on Heroku and using the add-on Proximo to proxy all outbound TCP traffic. When starting up, the logs show the following (Proxying traffic bound for 0.0.0.0/0 via Proximo host XX.XX.XX.XXX:1080). So, the Proximo add-on seems to be installed and configured correctly. However, the application comes to a halt due to the BindException. I don't start my own ServerSocket - it is handled by the Proximo add-in. – Søren Nødskov Hansen Dec 17 '12 at 10:04
  • I just did a netstat | grep "1080" (1080 is the port Proximo is trying to bind to) but nothing shows up (i.e. the port is unused). When trying to ping the IP alone, I get "Request timed out" and when trying to ping the IP on port 1080, I get "could not find host". I suspect that the IP (and port) Proximo is trying to bind to has to somehow be recognized by the server (Heroku runs off Amazon servers). Is there a way to achieve this? Any help is greatly appreciated. – Søren Nødskov Hansen Dec 17 '12 at 10:18
0

The proximo wrapper does not work with Java. Instead of using the wrapper, you will have to add some custom code to your app's initialization.

URL proximo = new URL(System.getenv("PROXIMO_URL"));
String userInfo = proximo.getUserInfo();
String user = userInfo.substring(0, userInfo.indexOf(':'));
String password = userInfo.substring(userInfo.indexOf(':') + 1);

System.setProperty("socksProxyHost", proximo.getHost());
Authenticator.setDefault(new ProxyAuthenticator(user, password));

And

private class ProxyAuthenticator extends Authenticator {
  private final PasswordAuthentication passwordAuthentication;

  private ProxyAuthenticator(String user, String password) {
    passwordAuthentication = new PasswordAuthentication(user, password.toCharArray());
  }

  @Override
  protected PasswordAuthentication getPasswordAuthentication() {
    return passwordAuthentication;
  }
}

The solution is described fully in this article.

codefinger
  • 10,088
  • 7
  • 39
  • 51